Forums: Update topic message counter on server update (#2524)

This commit is contained in:
Alexander Zinchuk 2023-02-08 00:47:57 +01:00
parent ca01d03190
commit 4b2c83b5ba
2 changed files with 14 additions and 0 deletions

View File

@ -594,6 +594,15 @@ export function updater(update: Update, originRequest?: GramJs.AnyRequest) {
lastReadOutboxMessageId: update.maxId,
},
});
} else if (update instanceof GramJs.UpdateReadChannelDiscussionInbox) {
onUpdate({
'@type': 'updateThreadInfo',
chatId: buildApiPeerId(update.channelId, 'channel'),
threadId: update.topMsgId,
threadInfo: {
lastReadInboxMessageId: update.readMaxId,
},
});
} else if (
update instanceof GramJs.UpdateDialogPinned
&& update.peer instanceof GramJs.DialogPeer

View File

@ -361,6 +361,11 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => {
global = replaceThreadParam(global, chatId, threadId, 'firstMessageId', firstMessageId);
}
const chat = selectChat(global, chatId);
if (chat?.isForum && threadInfo.lastReadInboxMessageId !== currentThreadInfo?.lastReadInboxMessageId) {
actions.loadTopicById({ chatId, topicId: threadId });
}
setGlobal(global);
break;