From e09d6a8d403a86a5fbf9473ac27efd9a663726e5 Mon Sep 17 00:00:00 2001 From: Eduard Kuzmenko Date: Wed, 13 Apr 2022 02:23:15 +0300 Subject: [PATCH] Fix second read check --- src/components/chat/bubbles.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/chat/bubbles.ts b/src/components/chat/bubbles.ts index 6fc8cdc4..747bde30 100644 --- a/src/components/chat/bubbles.ts +++ b/src/components/chat/bubbles.ts @@ -406,9 +406,10 @@ export default class ChatBubbles { //getHeavyAnimationPromise().then(() => { fastRaf(() => { - if(bubble.classList.contains('is-outgoing')) { + const mid = +bubble.dataset.mid; + if(bubbles[mid] === bubble && bubble.classList.contains('is-outgoing')) { bubble.classList.remove('is-sending', 'is-outgoing'); - bubble.classList.add(this.peerId === rootScope.myId && this.chat.type !== 'scheduled' ? 'is-read' : 'is-sent'); + bubble.classList.add((this.peerId === rootScope.myId && this.chat.type !== 'scheduled') || !this.unreadOut.has(mid) ? 'is-read' : 'is-sent'); } }); //}); @@ -754,7 +755,10 @@ export default class ChatBubbles { this.listenerSetter.add(rootScope)('dialog_unread', ({peerId}) => { if(peerId === this.peerId) { this.chat.input.setUnreadCount(); - this.updateUnreadByDialog(); + + getHeavyAnimationPromise().then(() => { + this.updateUnreadByDialog(); + }); } }); @@ -1900,6 +1904,8 @@ export default class ChatBubbles { if(msgId > 0 && msgId <= maxId) { const bubble = this.bubbles[msgId]; if(bubble) { + this.unreadOut.delete(msgId); + if(bubble.classList.contains('is-outgoing')) { continue; } @@ -1907,8 +1913,6 @@ export default class ChatBubbles { bubble.classList.remove('is-sent', 'is-sending', 'is-outgoing'); // is-sending can be when there are bulk of updates (e.g. sending command to Stickers bot) bubble.classList.add('is-read'); } - - this.unreadOut.delete(msgId); } } }