Chat List: Fix deleted chat remaining listed

This commit is contained in:
Alexander Zinchuk 2021-11-05 21:58:17 +03:00
parent 1f02f2b715
commit 1bcf27cc76

View File

@ -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 }),
},
});
}