Ensure that message heights are always recomputed

This commit is contained in:
Fedor Indutny 2021-11-30 20:34:56 +01:00 committed by GitHub
parent 77924918df
commit 518ebc315e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 5 deletions

View file

@ -81,6 +81,7 @@ export type PropsDataType = {
isNearBottom?: boolean; isNearBottom?: boolean;
items: ReadonlyArray<string>; items: ReadonlyArray<string>;
loadCountdownStart?: number; loadCountdownStart?: number;
messageHeightChangeBaton?: unknown;
messageHeightChangeIndex?: number; messageHeightChangeIndex?: number;
oldestUnreadIndex?: number; oldestUnreadIndex?: number;
resetCounter: number; resetCounter: number;
@ -132,7 +133,7 @@ export type PropsActionsType = {
acknowledgeGroupMemberNameCollisions: ( acknowledgeGroupMemberNameCollisions: (
groupNameCollisions: Readonly<GroupNameCollisionsWithIdsByTitle> groupNameCollisions: Readonly<GroupNameCollisionsWithIdsByTitle>
) => void; ) => void;
clearChangedMessages: (conversationId: string) => unknown; clearChangedMessages: (conversationId: string, baton: unknown) => unknown;
clearInvitedUuidsForNewlyCreatedGroup: () => void; clearInvitedUuidsForNewlyCreatedGroup: () => void;
closeContactSpoofingReview: () => void; closeContactSpoofingReview: () => void;
setLoadCountdownStart: ( setLoadCountdownStart: (
@ -1031,6 +1032,7 @@ export class Timeline extends React.PureComponent<PropsType, StateType> {
isIncomingMessageRequest, isIncomingMessageRequest,
items, items,
messageHeightChangeIndex, messageHeightChangeIndex,
messageHeightChangeBaton,
oldestUnreadIndex, oldestUnreadIndex,
resetCounter, resetCounter,
scrollToIndex, scrollToIndex,
@ -1088,7 +1090,7 @@ export class Timeline extends React.PureComponent<PropsType, StateType> {
if (isNumber(messageHeightChangeIndex)) { if (isNumber(messageHeightChangeIndex)) {
resizeStartRow = this.fromItemIndexToRow(messageHeightChangeIndex); resizeStartRow = this.fromItemIndexToRow(messageHeightChangeIndex);
clearChangedMessages(id); clearChangedMessages(id, messageHeightChangeBaton);
} }
if ( if (

View file

@ -622,6 +622,7 @@ export type ClearChangedMessagesActionType = {
type: 'CLEAR_CHANGED_MESSAGES'; type: 'CLEAR_CHANGED_MESSAGES';
payload: { payload: {
conversationId: string; conversationId: string;
baton: unknown;
}; };
}; };
export type ClearSelectedMessageActionType = { export type ClearSelectedMessageActionType = {
@ -1691,12 +1692,14 @@ function setRecentMediaItems(
}; };
} }
function clearChangedMessages( function clearChangedMessages(
conversationId: string conversationId: string,
baton: unknown
): ClearChangedMessagesActionType { ): ClearChangedMessagesActionType {
return { return {
type: 'CLEAR_CHANGED_MESSAGES', type: 'CLEAR_CHANGED_MESSAGES',
payload: { payload: {
conversationId, conversationId,
baton,
}, },
}; };
} }
@ -3048,10 +3051,14 @@ export function reducer(
} }
if (action.type === 'CLEAR_CHANGED_MESSAGES') { if (action.type === 'CLEAR_CHANGED_MESSAGES') {
const { payload } = action; const { payload } = action;
const { conversationId } = payload; const { conversationId, baton } = payload;
const existingConversation = state.messagesByConversation[conversationId]; const existingConversation = state.messagesByConversation[conversationId];
if (!existingConversation) { if (
!existingConversation ||
existingConversation.heightChangeMessageIds !== baton
) {
log.warn('CLEAR_CHANGED_MESSAGES used expired baton');
return state; return state;
} }

View file

@ -888,6 +888,7 @@ export function _conversationMessagesSelector(
loadCountdownStart, loadCountdownStart,
items, items,
isNearBottom, isNearBottom,
messageHeightChangeBaton: heightChangeMessageIds,
messageHeightChangeIndex: messageHeightChangeIndex:
isNumber(messageHeightChangeIndex) && messageHeightChangeIndex >= 0 isNumber(messageHeightChangeIndex) && messageHeightChangeIndex >= 0
? messageHeightChangeIndex ? messageHeightChangeIndex