Chat: Mark as read fixes (#6904)
This commit is contained in:
parent
6ca0fbfacb
commit
c89d8089a1
@ -514,6 +514,7 @@ export function updater(update: Update) {
|
|||||||
readState: {
|
readState: {
|
||||||
lastReadInboxMessageId: update.maxId,
|
lastReadInboxMessageId: update.maxId,
|
||||||
unreadCount: update.stillUnreadCount,
|
unreadCount: update.stillUnreadCount,
|
||||||
|
hasUnreadMark: undefined,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else if (update instanceof GramJs.UpdateReadHistoryOutbox) {
|
} else if (update instanceof GramJs.UpdateReadHistoryOutbox) {
|
||||||
@ -533,6 +534,7 @@ export function updater(update: Update) {
|
|||||||
readState: {
|
readState: {
|
||||||
lastReadInboxMessageId: update.maxId,
|
lastReadInboxMessageId: update.maxId,
|
||||||
unreadCount: update.stillUnreadCount,
|
unreadCount: update.stillUnreadCount,
|
||||||
|
hasUnreadMark: undefined,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else if (update instanceof GramJs.UpdateReadChannelOutbox) {
|
} else if (update instanceof GramJs.UpdateReadChannelOutbox) {
|
||||||
|
|||||||
@ -1516,6 +1516,7 @@ addActionHandler('markChatMessagesRead', async (global, actions, payload): Promi
|
|||||||
|
|
||||||
if (!result?.topics?.length) return;
|
if (!result?.topics?.length) return;
|
||||||
|
|
||||||
|
const topicIdsToMarkRead: number[] = [];
|
||||||
result.topics.forEach((topicWithState) => {
|
result.topics.forEach((topicWithState) => {
|
||||||
global = updateTopicWithState(global, id, topicWithState);
|
global = updateTopicWithState(global, id, topicWithState);
|
||||||
|
|
||||||
@ -1530,7 +1531,13 @@ addActionHandler('markChatMessagesRead', async (global, actions, payload): Promi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
actions.markTopicRead({ chatId: id, topicId: topicWithState.topic.id });
|
topicIdsToMarkRead.push(topicWithState.topic.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
setGlobal(global);
|
||||||
|
|
||||||
|
topicIdsToMarkRead.forEach((topicId) => {
|
||||||
|
actions.markTopicRead({ chatId: id, topicId });
|
||||||
});
|
});
|
||||||
|
|
||||||
lastTopic = result.topics[result.topics.length - 1].topic;
|
lastTopic = result.topics[result.topics.length - 1].topic;
|
||||||
@ -1539,6 +1546,10 @@ addActionHandler('markChatMessagesRead', async (global, actions, payload): Promi
|
|||||||
hasMoreTopics = false;
|
hasMoreTopics = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (chatReadState?.hasUnreadMark) {
|
||||||
|
actions.markChatRead({ id });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
addActionHandler('markChatRead', (global, actions, payload): ActionReturnType => {
|
addActionHandler('markChatRead', (global, actions, payload): ActionReturnType => {
|
||||||
|
|||||||
@ -1314,9 +1314,11 @@ addActionHandler('markMessageListRead', (global, actions, payload): ActionReturn
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const threadReadState = selectThreadReadState(global, chatId, threadId);
|
||||||
|
global = replaceThreadReadStateParam(global, chatId, threadId, 'hasUnreadMark', undefined);
|
||||||
|
|
||||||
const viewportIds = selectViewportIds(global, chatId, threadId, tabId);
|
const viewportIds = selectViewportIds(global, chatId, threadId, tabId);
|
||||||
const minId = selectFirstUnreadId(global, chatId, threadId);
|
const minId = selectFirstUnreadId(global, chatId, threadId);
|
||||||
const threadReadState = selectThreadReadState(global, chatId, threadId);
|
|
||||||
|
|
||||||
if (!viewportIds || !minId || !threadReadState?.unreadCount) {
|
if (!viewportIds || !minId || !threadReadState?.unreadCount) {
|
||||||
return global;
|
return global;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user