From 1bcf27cc762228b9638ad9a22a4d504816cb528f Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Fri, 5 Nov 2021 21:58:17 +0300 Subject: [PATCH] Chat List: Fix deleted chat remaining listed --- src/api/gramjs/methods/chats.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/api/gramjs/methods/chats.ts b/src/api/gramjs/methods/chats.ts index 945b01b2..3ed79b0b 100644 --- a/src/api/gramjs/methods/chats.ts +++ b/src/api/gramjs/methods/chats.ts @@ -277,23 +277,17 @@ export async function requestChatUpdate({ updateLocalDb(result); - let lastMessage: ApiMessage | undefined; - if (!noLastMessage) { - const lastRemoteMessage = buildApiMessage(result.messages[0]); - - if (lastLocalMessage && (!lastRemoteMessage || (lastLocalMessage.date > lastRemoteMessage.date))) { - lastMessage = lastLocalMessage; - } else { - lastMessage = lastRemoteMessage; - } - } + const lastRemoteMessage = buildApiMessage(result.messages[0]); + const lastMessage = lastLocalMessage && (!lastRemoteMessage || (lastLocalMessage.date > lastRemoteMessage.date)) + ? lastLocalMessage + : lastRemoteMessage; onUpdate({ '@type': 'updateChat', id, chat: { ...buildApiChatFromDialog(dialog, peerEntity, serverTimeOffset), - ...(lastMessage && { lastMessage }), + ...(!noLastMessage && { lastMessage }), }, }); }