diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2025-03-29 21:08:14 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2025-03-31 20:35:33 +0200 |
commit | 7a8e3fa16970296de6e553631fab7cfd67f461c2 (patch) | |
tree | 20de3e97ddfb80ee9542f6d7898caa6f694fa5eb /main | |
parent | 92fac6d75f0600f628ef459105385c0cf3f21e40 (diff) |
Keep weak reference to previous local state
Diffstat (limited to 'main')
-rw-r--r-- | main/State.hs | 5 | ||||
-rw-r--r-- | main/Test.hs | 9 |
2 files changed, 8 insertions, 6 deletions
diff --git a/main/State.hs b/main/State.hs index 76441df..d357844 100644 --- a/main/State.hs +++ b/main/State.hs @@ -44,14 +44,15 @@ loadLocalStateHead term st = loadHeads st >>= \case , ssValue = [ storedRef $ idExtData $ fromMaybe identity owner ] } storeHead st $ LocalState - { lsIdentity = idExtData identity + { lsPrev = Nothing + , lsIdentity = idExtData identity , lsShared = [ shared ] , lsOther = [] } updateSharedIdentity :: (MonadHead LocalState m, MonadError e m, FromErebosError e) => Terminal -> m () -updateSharedIdentity term = updateLocalHead_ $ updateSharedState_ $ \case +updateSharedIdentity term = updateLocalState_ $ updateSharedState_ $ \case Just identity -> do Just . toComposedIdentity <$> interactiveIdentityUpdate term identity Nothing -> throwOtherError "no existing shared identity" diff --git a/main/Test.hs b/main/Test.hs index 08ad880..e54285a 100644 --- a/main/Test.hs +++ b/main/Test.hs @@ -454,7 +454,8 @@ cmdCreateIdentity = do _ -> return [] storeHead st $ LocalState - { lsIdentity = idExtData identity + { lsPrev = Nothing + , lsIdentity = idExtData identity , lsShared = shared , lsOther = [] } @@ -646,7 +647,7 @@ cmdWatchSharedIdentity = do cmdUpdateLocalIdentity :: Command cmdUpdateLocalIdentity = do [name] <- asks tiParams - updateLocalHead_ $ \ls -> do + updateLocalState_ $ \ls -> do Just identity <- return $ validateExtendedIdentity $ lsIdentity $ fromStored ls let public = idKeyIdentity identity @@ -661,7 +662,7 @@ cmdUpdateLocalIdentity = do cmdUpdateSharedIdentity :: Command cmdUpdateSharedIdentity = do [name] <- asks tiParams - updateLocalHead_ $ updateSharedState_ $ \case + updateLocalState_ $ updateSharedState_ $ \case Nothing -> throwOtherError "no existing shared identity" Just identity -> do let public = idKeyIdentity identity @@ -731,7 +732,7 @@ cmdContactSetName :: Command cmdContactSetName = do [cid, name] <- asks tiParams contact <- getContact cid - updateLocalHead_ $ updateSharedState_ $ contactSetName contact name + updateLocalState_ $ updateSharedState_ $ contactSetName contact name cmdOut "contact-set-name-done" cmdDmSendPeer :: Command |