Message: Fix height jump on comments load (#4241)
This commit is contained in:
parent
af8aa64d8d
commit
1a7fedcb73
@ -135,8 +135,10 @@ export async function fetchChats({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (resultPinned) {
|
if (resultPinned) {
|
||||||
|
dispatchThreadInfoUpdates(resultPinned.messages);
|
||||||
updateLocalDb(resultPinned);
|
updateLocalDb(resultPinned);
|
||||||
}
|
}
|
||||||
|
dispatchThreadInfoUpdates(result.messages);
|
||||||
updateLocalDb(result);
|
updateLocalDb(result);
|
||||||
|
|
||||||
const messages = (resultPinned ? resultPinned.messages : [])
|
const messages = (resultPinned ? resultPinned.messages : [])
|
||||||
@ -144,8 +146,6 @@ export async function fetchChats({
|
|||||||
.map(buildApiMessage)
|
.map(buildApiMessage)
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
|
|
||||||
dispatchThreadInfoUpdates(result.messages);
|
|
||||||
|
|
||||||
const peersByKey = preparePeers(result);
|
const peersByKey = preparePeers(result);
|
||||||
if (resultPinned) {
|
if (resultPinned) {
|
||||||
Object.assign(peersByKey, preparePeers(resultPinned, peersByKey));
|
Object.assign(peersByKey, preparePeers(resultPinned, peersByKey));
|
||||||
|
|||||||
@ -51,7 +51,6 @@ import {
|
|||||||
buildApiMessage,
|
buildApiMessage,
|
||||||
buildApiSponsoredMessage,
|
buildApiSponsoredMessage,
|
||||||
buildApiThreadInfo,
|
buildApiThreadInfo,
|
||||||
buildApiThreadInfoFromMessage,
|
|
||||||
buildLocalForwardedMessage,
|
buildLocalForwardedMessage,
|
||||||
buildLocalMessage,
|
buildLocalMessage,
|
||||||
} from '../apiBuilders/messages';
|
} from '../apiBuilders/messages';
|
||||||
@ -1035,7 +1034,6 @@ export async function fetchDiscussionMessage({
|
|||||||
if (!threadId) return undefined;
|
if (!threadId) return undefined;
|
||||||
|
|
||||||
dispatchThreadInfoUpdates(result.messages);
|
dispatchThreadInfoUpdates(result.messages);
|
||||||
const threadInfoUpdates = result.messages.map(buildApiThreadInfoFromMessage).filter(Boolean);
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
unreadCount, maxId, readInboxMaxId, readOutboxMaxId,
|
unreadCount, maxId, readInboxMaxId, readOutboxMaxId,
|
||||||
@ -1053,7 +1051,6 @@ export async function fetchDiscussionMessage({
|
|||||||
lastMessageId: maxId,
|
lastMessageId: maxId,
|
||||||
chatId: topMessages[0]?.chatId,
|
chatId: topMessages[0]?.chatId,
|
||||||
firstMessageId: replies.messages[0]?.id,
|
firstMessageId: replies.messages[0]?.id,
|
||||||
threadInfoUpdates,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 0.5625rem 0.25rem 0.5625rem 0.625rem;
|
padding: 0.5rem 0.25rem 0.5rem 0.625rem;
|
||||||
padding-inline-start: 0.625rem;
|
padding-inline-start: 0.625rem;
|
||||||
padding-inline-end: 0.25rem;
|
padding-inline-end: 0.25rem;
|
||||||
background: var(--background-color);
|
background: var(--background-color);
|
||||||
@ -13,7 +13,7 @@
|
|||||||
border-bottom-left-radius: var(--border-bottom-left-radius);
|
border-bottom-left-radius: var(--border-bottom-left-radius);
|
||||||
font-size: 0.9375rem;
|
font-size: 0.9375rem;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
line-height: 2rem;
|
line-height: 2.125rem;
|
||||||
color: var(--accent-color);
|
color: var(--accent-color);
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
cursor: var(--custom-cursor, pointer);
|
cursor: var(--custom-cursor, pointer);
|
||||||
|
|||||||
@ -172,6 +172,7 @@ export const FAST_SMOOTH_SHORT_TRANSITION_MAX_DISTANCE = 300; // px
|
|||||||
export const API_UPDATE_THROTTLE = Math.round((FAST_SMOOTH_MIN_DURATION + FAST_SMOOTH_MAX_DURATION) / 2);
|
export const API_UPDATE_THROTTLE = Math.round((FAST_SMOOTH_MIN_DURATION + FAST_SMOOTH_MAX_DURATION) / 2);
|
||||||
export const API_THROTTLE_RESET_UPDATES = new Set([
|
export const API_THROTTLE_RESET_UPDATES = new Set([
|
||||||
'newMessage', 'newScheduledMessage', 'deleteMessages', 'deleteScheduledMessages', 'deleteHistory',
|
'newMessage', 'newScheduledMessage', 'deleteMessages', 'deleteScheduledMessages', 'deleteHistory',
|
||||||
|
'updateThreadInfos',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const LOCK_SCREEN_ANIMATION_DURATION_MS = 200;
|
export const LOCK_SCREEN_ANIMATION_DURATION_MS = 200;
|
||||||
|
|||||||
@ -91,7 +91,6 @@ addActionHandler('sync', (global, actions): ActionReturnType => {
|
|||||||
initFolderManager();
|
initFolderManager();
|
||||||
loadAllChats({ listType: 'archived', shouldReplace: true });
|
loadAllChats({ listType: 'archived', shouldReplace: true });
|
||||||
loadAllChats({ listType: 'saved', shouldReplace: true });
|
loadAllChats({ listType: 'saved', shouldReplace: true });
|
||||||
void callApi('fetchCurrentUser');
|
|
||||||
preloadTopChatMessages();
|
preloadTopChatMessages();
|
||||||
loadAllStories();
|
loadAllStories();
|
||||||
loadAllHiddenStories();
|
loadAllHiddenStories();
|
||||||
@ -167,6 +166,9 @@ async function loadAndReplaceMessages<T extends GlobalState>(global: T, actions:
|
|||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
|
const resultMessageIds = result.messages.map(({ id }) => id);
|
||||||
|
const messagesThreadInfos = pick(global.messages.byChatId[currentChatId].threadsById, resultMessageIds);
|
||||||
|
|
||||||
const isDiscussionStartLoaded = !result.messages.length
|
const isDiscussionStartLoaded = !result.messages.length
|
||||||
|| result.messages.some(({ id }) => id === resultDiscussion?.firstMessageId);
|
|| result.messages.some(({ id }) => id === resultDiscussion?.firstMessageId);
|
||||||
const threadStartMessages = (isDiscussionStartLoaded && resultDiscussion?.topMessages) || [];
|
const threadStartMessages = (isDiscussionStartLoaded && resultDiscussion?.topMessages) || [];
|
||||||
@ -194,12 +196,13 @@ async function loadAndReplaceMessages<T extends GlobalState>(global: T, actions:
|
|||||||
|
|
||||||
global = addChatMessagesById(global, currentChatId, byId);
|
global = addChatMessagesById(global, currentChatId, byId);
|
||||||
global = updateListedIds(global, currentChatId, activeThreadId, listedIds);
|
global = updateListedIds(global, currentChatId, activeThreadId, listedIds);
|
||||||
if (resultDiscussion) {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-loop-func
|
// eslint-disable-next-line @typescript-eslint/no-loop-func
|
||||||
resultDiscussion.threadInfoUpdates.forEach((update) => {
|
Object.entries(messagesThreadInfos).forEach(([id, thread]) => {
|
||||||
global = updateThreadInfo(global, currentChatId, activeThreadId, update);
|
if (!thread?.threadInfo) return;
|
||||||
});
|
global = updateThreadInfo(global, currentChatId, id, thread.threadInfo);
|
||||||
}
|
});
|
||||||
|
|
||||||
if (threadInfo && !threadInfo.isCommentsInfo && activeThreadId !== MAIN_THREAD_ID) {
|
if (threadInfo && !threadInfo.isCommentsInfo && activeThreadId !== MAIN_THREAD_ID) {
|
||||||
global = updateThreadInfo(global, currentChatId, activeThreadId, {
|
global = updateThreadInfo(global, currentChatId, activeThreadId, {
|
||||||
...pick(threadInfo, ['fromChannelId', 'fromMessageId']),
|
...pick(threadInfo, ['fromChannelId', 'fromMessageId']),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user