From 65905721245f979a656ec69204f3051d605744cf Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 2 Sep 2021 15:24:23 -0600 Subject: [PATCH] Improve performance of widget startup slightly See https://github.com/matrix-org/matrix-react-sdk/pull/6733#pullrequestreview-745513275 --- src/stores/widgets/StopGapWidget.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/stores/widgets/StopGapWidget.ts b/src/stores/widgets/StopGapWidget.ts index 0013c77e1c..750034c573 100644 --- a/src/stores/widgets/StopGapWidget.ts +++ b/src/stores/widgets/StopGapWidget.ts @@ -301,7 +301,8 @@ export class StopGapWidget extends EventEmitter { // requests timeline capabilities in other rooms down the road. It's just easier to manage here. for (const room of MatrixClientPeg.get().getRooms()) { // Timelines are most recent last - const roomEvent = arrayFastClone(room.getLiveTimeline()?.getEvents() || []).reverse()[0]; + const events = room.getLiveTimeline()?.getEvents() || []; + const roomEvent = events[events.length - 1]; if (!roomEvent) continue; // force later code to think the room is fresh this.readUpToMap[room.roomId] = roomEvent.getId(); }