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

View File

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

View File

@ -800,7 +800,9 @@ export function selectFirstUnreadId<T extends GlobalState>(
return ( return (
(!lastReadId || id > lastReadId) (!lastReadId || id > lastReadId)
&& byId[id] && 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 && id > lastReadServiceNotificationId
); );
}); });