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