From 33092f100e3605f0946b0feacc3cdf7e617a5050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Wed, 11 May 2022 16:28:15 +0200 Subject: [PATCH 1/3] Fix room history not being visible even if we have historical keys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/components/structures/TimelinePanel.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/structures/TimelinePanel.tsx b/src/components/structures/TimelinePanel.tsx index c92836e1a7b..2273fdd6d8d 100644 --- a/src/components/structures/TimelinePanel.tsx +++ b/src/components/structures/TimelinePanel.tsx @@ -806,16 +806,23 @@ class TimelinePanel extends React.Component { // Can be null for the notification timeline, etc. if (!this.props.timelineSet.room) return; + if (ev.getRoomId() !== this.props.timelineSet.room.roomId) return; + + if (!this.state.events.includes(ev)) return; + + const firstVisibleEventIndex = this.checkForPreJoinUISI(this.state.events); + if (firstVisibleEventIndex !== this.state.firstVisibleEventIndex) { + this.setState({ firstVisibleEventIndex }); + } + // Need to update as we don't display event tiles for events that // haven't yet been decrypted. The event will have just been updated // in place so we just need to re-render. // TODO: We should restrict this to only events in our timeline, // but possibly the event tile itself should just update when this // happens to save us re-rendering the whole timeline. - if (ev.getRoomId() === this.props.timelineSet.room.roomId) { - this.buildCallEventGroupers(this.state.events); - this.forceUpdate(); - } + this.buildCallEventGroupers(this.state.events); + this.forceUpdate(); }; private onSync = (clientSyncState: SyncState, prevState: SyncState, data: object): void => { From cebd65b60f64ddaeb980d5f4610eec232590c32d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Wed, 11 May 2022 16:51:36 +0200 Subject: [PATCH 2/3] Throttle `recheckFirstVisibleEventIndex()` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/components/structures/TimelinePanel.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/structures/TimelinePanel.tsx b/src/components/structures/TimelinePanel.tsx index 2273fdd6d8d..f53177bf5d7 100644 --- a/src/components/structures/TimelinePanel.tsx +++ b/src/components/structures/TimelinePanel.tsx @@ -24,7 +24,7 @@ import { TimelineWindow } from "matrix-js-sdk/src/timeline-window"; import { EventType, RelationType } from 'matrix-js-sdk/src/@types/event'; import { SyncState } from 'matrix-js-sdk/src/sync'; import { RoomMember, RoomMemberEvent } from 'matrix-js-sdk/src/models/room-member'; -import { debounce } from 'lodash'; +import { debounce, throttle } from 'lodash'; import { logger } from "matrix-js-sdk/src/logger"; import { ClientEvent } from "matrix-js-sdk/src/client"; import { Thread } from 'matrix-js-sdk/src/models/thread'; @@ -810,10 +810,13 @@ class TimelinePanel extends React.Component { if (!this.state.events.includes(ev)) return; - const firstVisibleEventIndex = this.checkForPreJoinUISI(this.state.events); - if (firstVisibleEventIndex !== this.state.firstVisibleEventIndex) { - this.setState({ firstVisibleEventIndex }); - } + const recheckFirstVisibleEventIndex = throttle(() => { + const firstVisibleEventIndex = this.checkForPreJoinUISI(this.state.events); + if (firstVisibleEventIndex !== this.state.firstVisibleEventIndex) { + this.setState({ firstVisibleEventIndex }); + } + }, 500, { leading: true, trailing: true }); + recheckFirstVisibleEventIndex(); // Need to update as we don't display event tiles for events that // haven't yet been decrypted. The event will have just been updated From 8792fcd7b72d2d6182cf2fcd8257774982f3ded4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Wed, 11 May 2022 16:55:18 +0200 Subject: [PATCH 3/3] Move `recheckFirstVisibleEventIndex()` out of `onEventDecrypted()` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/components/structures/TimelinePanel.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/components/structures/TimelinePanel.tsx b/src/components/structures/TimelinePanel.tsx index f53177bf5d7..9a115e99a82 100644 --- a/src/components/structures/TimelinePanel.tsx +++ b/src/components/structures/TimelinePanel.tsx @@ -810,13 +810,7 @@ class TimelinePanel extends React.Component { if (!this.state.events.includes(ev)) return; - const recheckFirstVisibleEventIndex = throttle(() => { - const firstVisibleEventIndex = this.checkForPreJoinUISI(this.state.events); - if (firstVisibleEventIndex !== this.state.firstVisibleEventIndex) { - this.setState({ firstVisibleEventIndex }); - } - }, 500, { leading: true, trailing: true }); - recheckFirstVisibleEventIndex(); + this.recheckFirstVisibleEventIndex(); // Need to update as we don't display event tiles for events that // haven't yet been decrypted. The event will have just been updated @@ -833,6 +827,13 @@ class TimelinePanel extends React.Component { this.setState({ clientSyncState }); }; + private recheckFirstVisibleEventIndex = throttle((): void => { + const firstVisibleEventIndex = this.checkForPreJoinUISI(this.state.events); + if (firstVisibleEventIndex !== this.state.firstVisibleEventIndex) { + this.setState({ firstVisibleEventIndex }); + } + }, 500, { leading: true, trailing: true }); + private readMarkerTimeout(readMarkerPosition: number): number { return readMarkerPosition === 0 ? this.context?.readMarkerInViewThresholdMs ?? this.state.readMarkerInViewThresholdMs :