Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 9027b23

Browse files
committed
Avoid re-calculating shouldShowEvent in getReadReceiptsByShownEvent
1 parent 3bbc867 commit 9027b23

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/components/structures/MessagePanel.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ export default class MessagePanel extends React.Component<IProps, IState> {
642642
// to assume that sent receipts are to be shown more often.
643643
this.readReceiptsByEvent = {};
644644
if (this.props.showReadReceipts) {
645-
this.readReceiptsByEvent = this.getReadReceiptsByShownEvent();
645+
this.readReceiptsByEvent = this.getReadReceiptsByShownEvent(events);
646646
}
647647

648648
let grouper: BaseGrouper = null;
@@ -862,7 +862,7 @@ export default class MessagePanel extends React.Component<IProps, IState> {
862862
// Get an object that maps from event ID to a list of read receipts that
863863
// should be shown next to that event. If a hidden event has read receipts,
864864
// they are folded into the receipts of the last shown event.
865-
private getReadReceiptsByShownEvent(): Record<string, IReadReceiptProps[]> {
865+
private getReadReceiptsByShownEvent(events: EventAndShouldShow[]): Record<string, IReadReceiptProps[]> {
866866
const receiptsByEvent: Record<string, IReadReceiptProps[]> = {};
867867
const receiptsByUserId: Record<
868868
string,
@@ -873,8 +873,8 @@ export default class MessagePanel extends React.Component<IProps, IState> {
873873
> = {};
874874

875875
let lastShownEventId;
876-
for (const event of this.props.events) {
877-
if (this.shouldShowEvent(event)) {
876+
for (const { event, shouldShow } of events) {
877+
if (shouldShow) {
878878
lastShownEventId = event.getId();
879879
}
880880
if (!lastShownEventId) {

0 commit comments

Comments
 (0)