From cbefbb47226d1532ecb94266abb23b082801fab9 Mon Sep 17 00:00:00 2001 From: Janne Mareike Koschinski Date: Fri, 14 Oct 2022 13:00:27 +0200 Subject: [PATCH] re-enable promise short-circuiting --- src/components/structures/TimelinePanel.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/components/structures/TimelinePanel.tsx b/src/components/structures/TimelinePanel.tsx index 01911c2768d1..fe7ecc824843 100644 --- a/src/components/structures/TimelinePanel.tsx +++ b/src/components/structures/TimelinePanel.tsx @@ -1409,6 +1409,18 @@ class TimelinePanel extends React.Component { // quite slow. So we detect that situation and shortcut straight to // calling _reloadEvents and updating the state. + // This is a hot-path optimization by skipping a promise tick + // by repeating a no-op sync branch in + // TimelineSet.getTimelineForEvent & MatrixClient.getEventTimeline + if (this.props.timelineSet.getTimelineForEvent(eventId)) { + // if we've got an eventId, and the timeline exists, we can skip + // the promise tick. + this.timelineWindow.load(eventId, INITIAL_SIZE); + // in this branch this method will happen in sync time + onLoaded(); + return; + } + const prom = this.timelineWindow.load(eventId, INITIAL_SIZE); this.buildLegacyCallEventGroupers(); this.setState({