Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/components/middle/ActionMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ const ActionMessage: FC<OwnProps & StateProps> = ({
getReceipt,
openGiftInfoModalFromMessage,
openPrizeStarsTransactionFromGiveaway,
markMentionsRead,
} = getActions();

const oldLang = useOldLang();
Expand Down Expand Up @@ -195,6 +196,12 @@ const ActionMessage: FC<OwnProps & StateProps> = ({
}
}, [isVisible, requestConfetti]);

useEffect(() => {
if (isVisible && message.hasUnreadMention) {
markMentionsRead({ messageIds: [message.id] });
}
}, [message.hasUnreadMention, isVisible]);

const { transitionClassNames } = useShowTransitionDeprecated(isShown, undefined, noAppearanceAnimation, false);

// No need for expensive global updates on users and chats, so we avoid them
Expand Down
15 changes: 14 additions & 1 deletion src/components/middle/message/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -850,8 +850,21 @@ const Message: FC<OwnProps & StateProps> = ({
animateUnreadReaction({ messageIds: [messageId] });
}

const unreadMentionsIds: number[] = [];
if (message.hasUnreadMention) {
markMentionsRead({ messageIds: [messageId] });
unreadMentionsIds.push(message.id);
}

if (album) {
for (const albumMessage of album.messages) {
if (albumMessage.hasUnreadMention) {
unreadMentionsIds.push(albumMessage.id);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would duplicate the main message id in albums. You could make unreadMentionIds re-assignable and write it like

if (album) {
  unreadMentionIds = album.messages.filter((msg) => msg.hasUnreadMention).map((msg) => msg.id);
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. I made an improvement.

}
}
}

if (unreadMentionsIds.length) {
markMentionsRead({ messageIds: unreadMentionsIds });
}
}, [hasUnreadReaction, messageId, animateUnreadReaction, message.hasUnreadMention]);

Expand Down