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
|
&& update.chatId === currentChatId
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const hasMention = Boolean(update.message.id && update.message.hasUnreadMention);
|
||||||
|
|
||||||
if (isActiveChat) {
|
if (isActiveChat) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
actions.requestChatUpdate({ chatId: update.chatId });
|
actions.requestChatUpdate({ chatId: update.chatId });
|
||||||
}, CURRENT_CHAT_UNREAD_DELAY);
|
}, 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, {
|
if (hasMention) {
|
||||||
unreadCount: chat.unreadCount ? chat.unreadCount + 1 : 1,
|
global = updateChat(global, update.chatId, {
|
||||||
...(update.message.id && update.message.hasUnreadMention && {
|
unreadMentions: [...(chat.unreadMentions || []), update.message.id!],
|
||||||
unreadMentionsCount: (chat.unreadMentionsCount || 0) + 1,
|
});
|
||||||
unreadMentions: [...(chat.unreadMentions || []), update.message.id],
|
}
|
||||||
}),
|
|
||||||
}));
|
setGlobal(global);
|
||||||
|
|
||||||
notifyAboutMessage({
|
notifyAboutMessage({
|
||||||
chat,
|
chat,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user