Chat List: Potential fix for stuck entries (#5048)
This commit is contained in:
parent
af3f767dcc
commit
dcdad5152e
@ -559,8 +559,8 @@ addActionHandler('loadFullChat', (global, actions, payload): ActionReturnType =>
|
||||
|
||||
addActionHandler('loadTopChats', (): ActionReturnType => {
|
||||
runThrottledForLoadTopChats(() => {
|
||||
loadChats('active');
|
||||
loadChats('archived');
|
||||
loadChats('active', undefined, true);
|
||||
loadChats('archived', undefined, true);
|
||||
});
|
||||
});
|
||||
|
||||
@ -2732,12 +2732,13 @@ addActionHandler('requestCollectibleInfo', async (global, actions, payload): Pro
|
||||
async function loadChats(
|
||||
listType: ChatListType,
|
||||
isFullDraftSync?: boolean,
|
||||
shouldIgnorePagination?: boolean,
|
||||
) {
|
||||
// eslint-disable-next-line eslint-multitab-tt/no-immediate-global
|
||||
let global = getGlobal();
|
||||
let lastLocalServiceMessageId = selectLastServiceNotification(global)?.id;
|
||||
|
||||
const params = selectChatListLoadingParameters(global, listType);
|
||||
const params = !shouldIgnorePagination ? selectChatListLoadingParameters(global, listType) : {};
|
||||
const offsetPeer = params.nextOffsetPeerId ? selectPeer(global, params.nextOffsetPeerId) : undefined;
|
||||
const offsetDate = params.nextOffsetDate;
|
||||
const offsetId = params.nextOffsetId;
|
||||
@ -2785,9 +2786,11 @@ async function loadChats(
|
||||
global = addMessages(global, result.messages);
|
||||
global = updateChatsLastMessageId(global, result.lastMessageByChatId, listType);
|
||||
|
||||
global = replaceChatListLoadingParameters(
|
||||
global, listType, result.nextOffsetId, result.nextOffsetPeerId, result.nextOffsetDate,
|
||||
);
|
||||
if (!shouldIgnorePagination) {
|
||||
global = replaceChatListLoadingParameters(
|
||||
global, listType, result.nextOffsetId, result.nextOffsetPeerId, result.nextOffsetDate,
|
||||
);
|
||||
}
|
||||
|
||||
const idsToUpdateDraft = isFullDraftSync ? result.chatIds : Object.keys(result.draftsById);
|
||||
idsToUpdateDraft.forEach((chatId) => {
|
||||
|
||||
@ -157,11 +157,11 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => {
|
||||
setGlobal(global);
|
||||
|
||||
// Reload dialogs if chat is not present in the list
|
||||
if (!selectIsChatListed(global, chatId)) {
|
||||
if (!isLocal && !selectIsChatListed(global, chatId)) {
|
||||
actions.loadTopChats();
|
||||
}
|
||||
|
||||
if (selectIsChatWithSelf(global, chatId) && !isLocal) {
|
||||
if (!isLocal && selectIsChatWithSelf(global, chatId)) {
|
||||
const savedDialogId = selectSavedDialogIdFromMessage(global, newMessage);
|
||||
if (savedDialogId && !selectIsChatListed(global, savedDialogId, 'saved')) {
|
||||
actions.requestSavedDialogUpdate({ chatId: savedDialogId });
|
||||
@ -359,6 +359,11 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => {
|
||||
lastReadInboxMessageId: message.id,
|
||||
});
|
||||
|
||||
// Reload dialogs if chat is not present in the list
|
||||
if (!selectIsChatListed(global, chatId)) {
|
||||
actions.loadTopChats();
|
||||
}
|
||||
|
||||
if (selectIsChatWithSelf(global, chatId)) {
|
||||
const savedDialogId = selectSavedDialogIdFromMessage(global, newMessage);
|
||||
if (savedDialogId && !selectIsChatListed(global, savedDialogId, 'saved')) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user