From 271f0dc6c1fe7f2f4482185688f2fe65555594d6 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin Date: Sat, 30 Nov 2024 20:29:38 +0000 Subject: [PATCH] simplify, make passed user active --- src/Simplex/Chat/Core.hs | 6 +++--- src/Simplex/Chat/Options.hs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Simplex/Chat/Core.hs b/src/Simplex/Chat/Core.hs index b3ee163c79..abe3099969 100644 --- a/src/Simplex/Chat/Core.hs +++ b/src/Simplex/Chat/Core.hs @@ -68,9 +68,9 @@ getSelectActiveUser :: SQLiteStore -> Maybe ContactName -> IO (Maybe User) getSelectActiveUser st displayName = do users <- withTransaction st getUsers case displayName of - Just name -> case find (\User {localDisplayName} -> localDisplayName == name) users of - Just u -> pure $ Just u - Nothing -> pure Nothing + Just name -> + forM (find (\User {localDisplayName} -> localDisplayName == name) users) $ \u -> + if activeUser u then pure u else withTransaction st (`setActiveUser` u) Nothing -> case find activeUser users of Just u -> pure $ Just u Nothing -> selectUser users diff --git a/src/Simplex/Chat/Options.hs b/src/Simplex/Chat/Options.hs index 0f0ebcc1df..90f04bf75a 100644 --- a/src/Simplex/Chat/Options.hs +++ b/src/Simplex/Chat/Options.hs @@ -293,7 +293,7 @@ chatOptsP appDir defaultDbFileName = do strOption ( long "display-name" <> metavar "DISPLAY_NAME" - <> help "Display name will be sent to your contacts when you connect and only stored on your device and you can change it later." + <> help "Create new or switch to existing user profile with this display name." ) chatCmd <- strOption