Message List: Fix topic unread count (#4554)
This commit is contained in:
parent
6e37c5b163
commit
5f4103f64f
@ -958,6 +958,12 @@ export async function markMessageListRead({
|
|||||||
|
|
||||||
if (threadId === MAIN_THREAD_ID) {
|
if (threadId === MAIN_THREAD_ID) {
|
||||||
void requestChatUpdate({ chat, noLastMessage: true });
|
void requestChatUpdate({ chat, noLastMessage: true });
|
||||||
|
} else if (chat.isForum) {
|
||||||
|
onUpdate({
|
||||||
|
'@type': 'updateTopic',
|
||||||
|
chatId: chat.id,
|
||||||
|
topicId: Number(threadId),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -857,7 +857,7 @@ addActionHandler('markMessageListRead', (global, actions, payload): ActionReturn
|
|||||||
return global;
|
return global;
|
||||||
}
|
}
|
||||||
|
|
||||||
const readCount = countSortedIds(viewportIds!, minId, maxId);
|
const readCount = countSortedIds(viewportIds, minId, maxId);
|
||||||
if (!readCount) {
|
if (!readCount) {
|
||||||
return global;
|
return global;
|
||||||
}
|
}
|
||||||
@ -2136,6 +2136,9 @@ addActionHandler('copyMessageLink', async (global, actions, payload): Promise<vo
|
|||||||
});
|
});
|
||||||
|
|
||||||
function countSortedIds(ids: number[], from: number, to: number) {
|
function countSortedIds(ids: number[], from: number, to: number) {
|
||||||
|
// If ids are outside viewport, we cannot get correct count
|
||||||
|
if (ids.length === 0 || from < ids[0] || to > ids[ids.length - 1]) return undefined;
|
||||||
|
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
||||||
for (let i = 0, l = ids.length; i < l; i++) {
|
for (let i = 0, l = ids.length; i < l; i++) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user