Chat List: Fix disappearing entries (#5334)
This commit is contained in:
parent
f9a05956b7
commit
55170dc047
@ -55,6 +55,7 @@ import {
|
|||||||
addActionHandler, getGlobal, setGlobal,
|
addActionHandler, getGlobal, setGlobal,
|
||||||
} from '../../index';
|
} from '../../index';
|
||||||
import {
|
import {
|
||||||
|
addChatListIds,
|
||||||
addChatMembers,
|
addChatMembers,
|
||||||
addChats,
|
addChats,
|
||||||
addMessages,
|
addMessages,
|
||||||
@ -76,7 +77,6 @@ import {
|
|||||||
updateChat,
|
updateChat,
|
||||||
updateChatFullInfo,
|
updateChatFullInfo,
|
||||||
updateChatLastMessageId,
|
updateChatLastMessageId,
|
||||||
updateChatListIds,
|
|
||||||
updateChatListSecondaryInfo,
|
updateChatListSecondaryInfo,
|
||||||
updateChats,
|
updateChats,
|
||||||
updateChatsLastMessageId,
|
updateChatsLastMessageId,
|
||||||
@ -600,7 +600,7 @@ addActionHandler('requestSavedDialogUpdate', async (global, actions, payload): P
|
|||||||
|
|
||||||
if (result.messages.length) {
|
if (result.messages.length) {
|
||||||
global = updateChatLastMessageId(global, chatId, result.messages[0].id, 'saved');
|
global = updateChatLastMessageId(global, chatId, result.messages[0].id, 'saved');
|
||||||
global = updateChatListIds(global, 'saved', [chatId]);
|
global = addChatListIds(global, 'saved', [chatId]);
|
||||||
|
|
||||||
setGlobal(global);
|
setGlobal(global);
|
||||||
} else {
|
} else {
|
||||||
@ -2748,7 +2748,7 @@ async function loadChats(
|
|||||||
const offsetDate = params.nextOffsetDate;
|
const offsetDate = params.nextOffsetDate;
|
||||||
const offsetId = params.nextOffsetId;
|
const offsetId = params.nextOffsetId;
|
||||||
|
|
||||||
const isFirstBatch = !offsetPeer && !offsetDate && !offsetId;
|
const isFirstBatch = !shouldIgnorePagination && !offsetPeer && !offsetDate && !offsetId;
|
||||||
|
|
||||||
const result = listType === 'saved' ? await callApi('fetchSavedChats', {
|
const result = listType === 'saved' ? await callApi('fetchSavedChats', {
|
||||||
limit: CHAT_LIST_LOAD_SLICE,
|
limit: CHAT_LIST_LOAD_SLICE,
|
||||||
@ -2783,7 +2783,7 @@ async function loadChats(
|
|||||||
global = replaceChatListIds(global, listType, chatIds);
|
global = replaceChatListIds(global, listType, chatIds);
|
||||||
global = replaceUserStatuses(global, result.userStatusesById);
|
global = replaceUserStatuses(global, result.userStatusesById);
|
||||||
} else {
|
} else {
|
||||||
global = updateChatListIds(global, listType, chatIds);
|
global = addChatListIds(global, listType, chatIds);
|
||||||
global = addUserStatuses(global, result.userStatusesById);
|
global = addUserStatuses(global, result.userStatusesById);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import {
|
|||||||
addActionHandler, getGlobal, setGlobal,
|
addActionHandler, getGlobal, setGlobal,
|
||||||
} from '../../index';
|
} from '../../index';
|
||||||
import {
|
import {
|
||||||
|
addChatListIds,
|
||||||
addUnreadMentions,
|
addUnreadMentions,
|
||||||
deleteChatMessages,
|
deleteChatMessages,
|
||||||
deletePeerPhoto,
|
deletePeerPhoto,
|
||||||
@ -21,7 +22,6 @@ import {
|
|||||||
replaceThreadParam,
|
replaceThreadParam,
|
||||||
updateChat,
|
updateChat,
|
||||||
updateChatFullInfo,
|
updateChatFullInfo,
|
||||||
updateChatListIds,
|
|
||||||
updateChatListType,
|
updateChatListType,
|
||||||
updatePeerStoriesHidden,
|
updatePeerStoriesHidden,
|
||||||
updateTopic,
|
updateTopic,
|
||||||
@ -114,7 +114,7 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
global = getGlobal();
|
global = getGlobal();
|
||||||
global = updateChatListIds(global, listType, [update.id]);
|
global = addChatListIds(global, listType, [update.id]);
|
||||||
setGlobal(global);
|
setGlobal(global);
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
@ -166,7 +166,7 @@ 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 (!isLocal && !selectIsChatListed(global, chatId)) {
|
if (!isLocal && chat && !chat.isNotJoined && !selectIsChatListed(global, chatId)) {
|
||||||
actions.loadTopChats();
|
actions.loadTopChats();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,8 +444,9 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => {
|
|||||||
lastReadInboxMessageId: message.id,
|
lastReadInboxMessageId: message.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const chat = selectChat(global, chatId);
|
||||||
// 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 (chat && !chat.isNotJoined && !selectIsChatListed(global, chatId)) {
|
||||||
actions.loadTopChats();
|
actions.loadTopChats();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -86,7 +86,7 @@ export function updateChatsLastMessageId<T extends GlobalState>(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateChatListIds<T extends GlobalState>(
|
export function addChatListIds<T extends GlobalState>(
|
||||||
global: T, type: ChatListType, idsUpdate: string[],
|
global: T, type: ChatListType, idsUpdate: string[],
|
||||||
): T {
|
): T {
|
||||||
const { [type]: listIds } = global.chats.listIds;
|
const { [type]: listIds } = global.chats.listIds;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user