Fix instant reading voice/round messages

This commit is contained in:
morethanwords 2021-09-15 15:19:59 +04:00
parent 1afeacf368
commit 0014fd6319
2 changed files with 12 additions and 2 deletions

View File

@ -776,7 +776,7 @@ export default class ChatBubbles {
const readContents: number[] = [];
for(const mid of this.unreadedSeen) {
const message: MyMessage = this.chat.getMessage(mid);
if(message.pFlags.media_unread) {
if(this.appMessagesManager.isMentionUnread(message)) {
readContents.push(mid);
}
}
@ -2170,7 +2170,7 @@ export default class ChatBubbles {
if(!our && !message.pFlags.out && this.unreadedObserver) {
//this.log('not our message', message, message.pFlags.unread);
const isUnread = message.pFlags.unread ||
(message.pFlags.media_unread && message.pFlags.mentioned) ||
this.appMessagesManager.isMentionUnread(message) ||
(this.historyStorage.readMaxId !== undefined && this.historyStorage.readMaxId < message.mid);
if(isUnread) {
this.unreadedObserver.observe(bubble);

View File

@ -5438,6 +5438,16 @@ export class AppMessagesManager {
)
);
}
public isMentionUnread(message: MyMessage) {
const doc = ((message as Message.message).media as MessageMedia.messageMediaDocument)?.document as MyDocument;
return message.pFlags.media_unread &&
message.pFlags.mentioned &&
(
!doc ||
!(['voice', 'round'] as MyDocument['type'][]).includes(doc.type)
);
}
}
const appMessagesManager = new AppMessagesManager();