simplify, make passed user active

This commit is contained in:
Evgeny Poberezkin
2024-11-30 20:29:38 +00:00
parent ecbcf05218
commit 271f0dc6c1
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -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
+1 -1
View File
@@ -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