Merge pull request #6734 from matrix-org/travis/widget-algo

Improve performance of widget startup slightly
This commit is contained in:
Travis Ralston 2021-09-02 16:02:11 -06:00 committed by GitHub
commit 1772e7e314
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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. // requests timeline capabilities in other rooms down the road. It's just easier to manage here.
for (const room of MatrixClientPeg.get().getRooms()) { for (const room of MatrixClientPeg.get().getRooms()) {
// Timelines are most recent last // 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 if (!roomEvent) continue; // force later code to think the room is fresh
this.readUpToMap[room.roomId] = roomEvent.getId(); this.readUpToMap[room.roomId] = roomEvent.getId();
} }