Remove key caching from Timeline

This commit is contained in:
Fedor Indutny 2021-09-28 11:32:54 -07:00 committed by GitHub
parent 1303fd009e
commit 2f7226e200
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 10 deletions

View File

@ -752,7 +752,6 @@ export class Timeline extends React.PureComponent<PropsType, StateType> {
const typingBubbleRow = this.getTypingBubbleRow();
let rowContents: ReactNode;
let stableKey = key;
if (haveOldest && row === 0) {
rowContents = (
<div data-row={row} style={styleWithWidth} role="row">
@ -800,7 +799,6 @@ export class Timeline extends React.PureComponent<PropsType, StateType> {
const previousMessageId: undefined | string = items[itemIndex - 1];
const messageId = items[itemIndex];
const nextMessageId: undefined | string = items[itemIndex + 1];
stableKey = messageId;
const actionProps = getActions(this.props);
@ -831,7 +829,7 @@ export class Timeline extends React.PureComponent<PropsType, StateType> {
<CellMeasurer
cache={this.cellSizeCache}
columnIndex={0}
key={stableKey}
key={key}
parent={parent}
rowIndex={index}
width={this.mostRecentWidth}

View File

@ -2328,13 +2328,6 @@ export function reducer(
? existingConversation.resetCounter + 1
: 0;
const sorted = orderBy(
messages,
['received_at', 'sent_at'],
['ASC', 'ASC']
);
const messageIds = sorted.map(message => message.id);
const lookup = fromPairs(messages.map(message => [message.id, message]));
let { newest, oldest } = metrics;
@ -2355,6 +2348,13 @@ export function reducer(
}
}
const sorted = orderBy(
values(lookup),
['received_at', 'sent_at'],
['ASC', 'ASC']
);
const messageIds = sorted.map(message => message.id);
return {
...state,
selectedMessage: scrollToMessageId,