mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-28 18:18:15 +00:00
mobile: use updated_at in chat previews (#671)
* mobile: use updated_at in chat previews * use updated_at returned from chat response * refactor Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
This commit is contained in:
co-authored by
Evgeny Poberezkin
parent
9c9f6d8443
commit
3f2ca8f902
+14
-8
@@ -407,10 +407,13 @@ processChatCommand = \case
|
||||
cancelFile user fileInfo
|
||||
withFilesFolder $ \filesFolder -> deleteFile filesFolder fileInfo
|
||||
void $ withStore $ \st -> deleteDirectChatItemLocal st userId ct itemId CIDMInternal
|
||||
let latestItem = if not $ null ciIdsAndFileInfo then Just (last ciIdsAndFileInfo) else Nothing
|
||||
forM_ latestItem $ \(_, latestItemTs, _) ->
|
||||
withStore $ \st -> updateContactTs st user ct latestItemTs
|
||||
pure $ CRChatCleared (AChatInfo SCTDirect (DirectChat ct))
|
||||
ct' <- case ciIdsAndFileInfo of
|
||||
[] -> pure ct
|
||||
_ -> do
|
||||
let (_, lastItemTs, _) = last ciIdsAndFileInfo
|
||||
withStore (\st -> updateContactTs st user ct lastItemTs)
|
||||
pure (ct :: Contact) {updatedAt = lastItemTs}
|
||||
pure $ CRChatCleared (AChatInfo SCTDirect (DirectChat ct'))
|
||||
CTGroup -> do
|
||||
gInfo <- withStore $ \st -> getGroupInfo st user chatId
|
||||
ciIdsAndFileInfo <- withStore $ \st -> getGroupChatItemIdsAndFileInfo st user chatId
|
||||
@@ -420,10 +423,13 @@ processChatCommand = \case
|
||||
cancelFile user fileInfo
|
||||
withFilesFolder $ \filesFolder -> deleteFile filesFolder fileInfo
|
||||
void $ withStore $ \st -> deleteGroupChatItemInternal st user gInfo itemId
|
||||
let latestItem = if not $ null ciIdsAndFileInfo then Just (last ciIdsAndFileInfo) else Nothing
|
||||
forM_ latestItem $ \(_, latestItemTs, _, _) ->
|
||||
withStore $ \st -> updateGroupTs st user gInfo latestItemTs
|
||||
pure $ CRChatCleared (AChatInfo SCTGroup (GroupChat gInfo))
|
||||
gInfo' <- case ciIdsAndFileInfo of
|
||||
[] -> pure gInfo
|
||||
_ -> do
|
||||
let (_, lastItemTs, _, _) = last ciIdsAndFileInfo
|
||||
withStore (\st -> updateGroupTs st user gInfo lastItemTs)
|
||||
pure (gInfo :: GroupInfo) {updatedAt = lastItemTs}
|
||||
pure $ CRChatCleared (AChatInfo SCTGroup (GroupChat gInfo'))
|
||||
CTContactConnection -> pure $ chatCmdError "not supported"
|
||||
CTContactRequest -> pure $ chatCmdError "not supported"
|
||||
APIAcceptContact connReqId -> withUser $ \user@User {userId} -> withChatLock $ do
|
||||
|
||||
Reference in New Issue
Block a user