From cbdbc0a176736b3be970f263f2319a0f6bd123bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Tue, 5 Aug 2025 21:28:55 +0200 Subject: Use MonadStorage for createIdentity Changelog: API: `Identity.createIdentity` uses `MonadStorage` --- main/Main.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'main/Main.hs') diff --git a/main/Main.hs b/main/Main.hs index a3b74b1..5bda7e7 100644 --- a/main/Main.hs +++ b/main/Main.hs @@ -287,7 +287,7 @@ main = do ["update-identity"] -> do withTerminal noCompletion $ \term -> do either (fail . showErebosError) return <=< runExceptT $ do - runReaderT (updateSharedIdentity term) =<< loadLocalStateHead term st + runReaderT (updateSharedIdentity term) =<< runReaderT (loadLocalStateHead term) st ("update-identity" : srefs) -> do withTerminal noCompletion $ \term -> do @@ -329,9 +329,10 @@ main = do interactiveLoop :: Storage -> Options -> IO () interactiveLoop st opts = withTerminal commandCompletion $ \term -> do - erebosHead <- case optCreateIdentity opts of - Nothing -> loadLocalStateHead term st - Just ( devName, names ) -> createLocalStateHead st (names ++ [ devName ]) + erebosHead <- either (fail . showErebosError) return <=< runExceptT . flip runReaderT st $ do + case optCreateIdentity opts of + Nothing -> loadLocalStateHead term + Just ( devName, names ) -> createLocalStateHead (names ++ [ devName ]) void $ printLine term $ T.unpack $ displayIdentity $ headLocalIdentity erebosHead let tui = hasTerminalUI term @@ -703,8 +704,7 @@ cmdJoin = joinChatroom =<< getSelectedChatroom cmdJoinAs :: Command cmdJoinAs = do name <- asks ciLine - st <- getStorage - identity <- liftIO $ createIdentity st (Just $ T.pack name) Nothing + identity <- createIdentity (Just $ T.pack name) Nothing joinChatroomAs identity =<< getSelectedChatroom cmdLeave :: Command -- cgit v1.2.3