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

Commit a4ea5b5

Browse files
authored
Merge pull request #4740 from matrix-org/travis/room-list/stability-1
Improve general stability in the new room list
2 parents 95b4abb + 84174cc commit a4ea5b5

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

src/components/structures/UserMenuButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export default class UserMenuButton extends React.Component<IProps, IState> {
8080
private isUserOnDarkTheme(): boolean {
8181
const theme = SettingsStore.getValue("theme");
8282
if (theme.startsWith("custom-")) {
83-
return getCustomTheme(theme.substring(0, 7)).is_dark;
83+
return getCustomTheme(theme.substring("custom-".length)).is_dark;
8484
}
8585
return theme === "dark";
8686
}

src/stores/room-list/RoomListStoreTempProxy.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@ export class RoomListStoreTempProxy {
3131
return SettingsStore.isFeatureEnabled("feature_new_room_list");
3232
}
3333

34-
public static addListener(handler: () => void) {
34+
public static addListener(handler: () => void): RoomListStoreTempToken {
3535
if (RoomListStoreTempProxy.isUsingNewStore()) {
36-
return RoomListStore.instance.on(UPDATE_EVENT, handler);
36+
const offFn = () => RoomListStore.instance.off(UPDATE_EVENT, handler);
37+
RoomListStore.instance.on(UPDATE_EVENT, handler);
38+
return new RoomListStoreTempToken(offFn);
3739
} else {
38-
return OldRoomListStore.addListener(handler);
40+
const token = OldRoomListStore.addListener(handler);
41+
return new RoomListStoreTempToken(() => token.remove());
3942
}
4043
}
4144

@@ -47,3 +50,12 @@ export class RoomListStoreTempProxy {
4750
}
4851
}
4952
}
53+
54+
export class RoomListStoreTempToken {
55+
constructor(private offFn: () => void) {
56+
}
57+
58+
public remove(): void {
59+
this.offFn();
60+
}
61+
}

src/stores/room-list/TagWatcher.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ export class TagWatcher {
7474
this.store.removeFilter(filter);
7575
}
7676

77+
// Destroy any and all old filter conditions to prevent resource leaks
78+
for (const filter of this.filters.values()) {
79+
filter.destroy();
80+
}
81+
7782
this.filters = newFilters;
7883
}
7984
};

0 commit comments

Comments
 (0)