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

Commit 80cf283

Browse files
committed
Ensure breadcrumbs don't keep turning themselves back on
Fixes element-hq/element-web#14452
1 parent d182961 commit 80cf283

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/stores/BreadcrumbsStore.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { AsyncStoreWithClient } from "./AsyncStoreWithClient";
2121
import defaultDispatcher from "../dispatcher/dispatcher";
2222
import { arrayHasDiff } from "../utils/arrays";
2323
import { RoomListStoreTempProxy } from "./room-list/RoomListStoreTempProxy";
24+
import { isNullOrUndefined } from "matrix-js-sdk/src/utils";
2425

2526
const MAX_ROOMS = 20; // arbitrary
2627
const AUTOJOIN_WAIT_THRESHOLD_MS = 90000; // 90s, the time we wait for an autojoined room to show up
@@ -51,7 +52,11 @@ export class BreadcrumbsStore extends AsyncStoreWithClient<IState> {
5152
}
5253

5354
public get visible(): boolean {
54-
return this.state.enabled && this.matrixClient.getVisibleRooms().length >= 20;
55+
return this.state.enabled && this.meetsRoomRequirement;
56+
}
57+
58+
private get meetsRoomRequirement(): boolean {
59+
return this.matrixClient.getVisibleRooms().length >= 20;
5560
}
5661

5762
protected async onAction(payload: ActionPayload) {
@@ -99,8 +104,9 @@ export class BreadcrumbsStore extends AsyncStoreWithClient<IState> {
99104
}
100105

101106
private onMyMembership = async (room: Room) => {
102-
// We turn on breadcrumbs by default once the user has at least 1 room to show.
103-
if (!this.state.enabled) {
107+
// Only turn on breadcrumbs is the user hasn't explicitly turned it off again.
108+
const settingValueRaw = SettingsStore.getValue("breadcrumbs", null, /*excludeDefault=*/true);
109+
if (this.meetsRoomRequirement && isNullOrUndefined(settingValueRaw)) {
104110
await SettingsStore.setValue("breadcrumbs", null, SettingLevel.ACCOUNT, true);
105111
}
106112
};

0 commit comments

Comments
 (0)