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

Commit 40ab3e2

Browse files
committed
Add a null guard on the client
1 parent 9a3744e commit 40ab3e2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/stores/room-list/algorithms/tag-sorting/RecentAlgorithm.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ export class RecentAlgorithm implements IAlgorithm {
3838
// actually changed (probably needs to be done higher up?) then we could do an
3939
// insertion sort or similar on the limited set of changes.
4040

41-
const myUserId = MatrixClientPeg.get().getUserId();
41+
// TODO: Don't assume we're using the same client as the peg
42+
let myUserId = '';
43+
if (MatrixClientPeg.get()) {
44+
myUserId = MatrixClientPeg.get().getUserId();
45+
}
4246

4347
const tsCache: { [roomId: string]: number } = {};
4448
const getLastTs = (r: Room) => {
@@ -68,7 +72,6 @@ export class RecentAlgorithm implements IAlgorithm {
6872
const ev = r.timeline[i];
6973
if (!ev.getTs()) continue; // skip events that don't have timestamps (tests only?)
7074

71-
// TODO: Don't assume we're using the same client as the peg
7275
if (ev.getSender() === myUserId || Unread.eventTriggersUnreadCount(ev)) {
7376
return ev.getTs();
7477
}

0 commit comments

Comments
 (0)