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

Improve general stability in the new room list #4740

Merged
merged 4 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/structures/UserMenuButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default class UserMenuButton extends React.Component<IProps, IState> {
private isUserOnDarkTheme(): boolean {
const theme = SettingsStore.getValue("theme");
if (theme.startsWith("custom-")) {
return getCustomTheme(theme.substring(0, 7)).is_dark;
return getCustomTheme(theme.substring("custom-".length)).is_dark;
}
return theme === "dark";
}
Expand Down
18 changes: 15 additions & 3 deletions src/stores/room-list/RoomListStoreTempProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ export class RoomListStoreTempProxy {
return SettingsStore.isFeatureEnabled("feature_new_room_list");
}

public static addListener(handler: () => void) {
public static addListener(handler: () => void): RoomListStoreTempToken {
if (RoomListStoreTempProxy.isUsingNewStore()) {
return RoomListStore.instance.on(UPDATE_EVENT, handler);
const offFn = () => RoomListStore.instance.off(UPDATE_EVENT, handler);
RoomListStore.instance.on(UPDATE_EVENT, handler);
return new RoomListStoreTempToken(offFn);
} else {
return OldRoomListStore.addListener(handler);
const token = OldRoomListStore.addListener(handler);
return new RoomListStoreTempToken(() => token.remove());
}
}

Expand All @@ -47,3 +50,12 @@ export class RoomListStoreTempProxy {
}
}
}

export class RoomListStoreTempToken {
constructor(private offFn: () => void) {
}

public remove(): void {
this.offFn();
}
}
5 changes: 5 additions & 0 deletions src/stores/room-list/TagWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ export class TagWatcher {
this.store.removeFilter(filter);
}

// Destroy any and all old filter conditions to prevent resource leaks
for (const filter of this.filters.values()) {
filter.destroy();
}

this.filters = newFilters;
}
};
Expand Down