Forums: Fix stuck unread badge when editing topics (#2701)

This commit is contained in:
Alexander Zinchuk 2023-03-03 14:30:29 +01:00
parent 90d3121da8
commit 893fa8f557
3 changed files with 7 additions and 1 deletions

View File

@ -899,6 +899,7 @@ function buildAction(
let score: number | undefined;
let months: number | undefined;
let topicEmojiIconId: string | undefined;
let isTopicAction: boolean | undefined;
const targetUserIds = 'users' in action
? action.users && action.users.map((id) => buildApiPeerId(id, 'user'))
@ -1063,6 +1064,7 @@ function buildAction(
} else {
text = 'ChatList.UnsupportedMessage';
}
isTopicAction = true;
} else if (action instanceof GramJs.MessageActionAttachMenuBotAllowed) {
text = 'ActionAttachMenuBotAllowed';
} else if (action instanceof GramJs.MessageActionSuggestProfilePhoto) {
@ -1097,6 +1099,7 @@ function buildAction(
score,
months,
topicEmojiIconId,
isTopicAction,
};
}

View File

@ -273,6 +273,7 @@ export interface ApiAction {
score?: number;
months?: number;
topicEmojiIconId?: string;
isTopicAction?: boolean;
}
export interface ApiWebPage {

View File

@ -800,7 +800,9 @@ export function selectFirstUnreadId<T extends GlobalState>(
return (
(!lastReadId || id > lastReadId)
&& byId[id]
&& (!byId[id].isOutgoing || byId[id].isFromScheduled)
// For some reason outgoing topic actions are not marked as read, thus we need to mark them as read
// when the edit message hits the viewport
&& ((!byId[id].isOutgoing || byId[id].content.action?.isTopicAction) || byId[id].isFromScheduled)
&& id > lastReadServiceNotificationId
);
});