Chat: Fix flickering badge for incoming message in current chat
This commit is contained in:
parent
d0735fcc0e
commit
dc41aa0ea9
@ -105,19 +105,26 @@ addActionHandler('apiUpdate', (global, actions, update) => {
|
||||
&& update.chatId === currentChatId
|
||||
);
|
||||
|
||||
const hasMention = Boolean(update.message.id && update.message.hasUnreadMention);
|
||||
|
||||
if (isActiveChat) {
|
||||
setTimeout(() => {
|
||||
actions.requestChatUpdate({ chatId: update.chatId });
|
||||
}, CURRENT_CHAT_UNREAD_DELAY);
|
||||
} else {
|
||||
global = updateChat(global, update.chatId, {
|
||||
unreadCount: (chat.unreadCount || 0) + 1,
|
||||
...(hasMention && { unreadMentionsCount: (chat.unreadMentionsCount || 0) + 1 }),
|
||||
});
|
||||
}
|
||||
|
||||
setGlobal(updateChat(global, update.chatId, {
|
||||
unreadCount: chat.unreadCount ? chat.unreadCount + 1 : 1,
|
||||
...(update.message.id && update.message.hasUnreadMention && {
|
||||
unreadMentionsCount: (chat.unreadMentionsCount || 0) + 1,
|
||||
unreadMentions: [...(chat.unreadMentions || []), update.message.id],
|
||||
}),
|
||||
}));
|
||||
if (hasMention) {
|
||||
global = updateChat(global, update.chatId, {
|
||||
unreadMentions: [...(chat.unreadMentions || []), update.message.id!],
|
||||
});
|
||||
}
|
||||
|
||||
setGlobal(global);
|
||||
|
||||
notifyAboutMessage({
|
||||
chat,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user