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

Space Panel use SettingsStore instead of SpaceStore as source of truth #7404

Merged
merged 2 commits into from
Dec 17, 2021
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
4 changes: 1 addition & 3 deletions src/components/views/spaces/SpacePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ export const HomeButtonContextMenu = ({
hideHeader,
...props
}: ComponentProps<typeof SpaceContextMenu>) => {
const allRoomsInHome = useEventEmitterState(SpaceStore.instance, UPDATE_HOME_BEHAVIOUR, () => {
return SpaceStore.instance.allRoomsInHome;
});
const allRoomsInHome = useSettingValue<boolean>("Spaces.allRoomsInHome");

return <IconizedContextMenu
{...props}
Expand Down
7 changes: 5 additions & 2 deletions src/stores/spaces/SpaceStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
private _invitedSpaces = new Set<Room>();
private spaceOrderLocalEchoMap = new Map<string, string>();
private _restrictedJoinRuleSupport?: IRoomCapability;
private _allRoomsInHome: boolean = SettingsStore.getValue("Spaces.allRoomsInHome");
private _enabledMetaSpaces: MetaSpace[] = []; // set by onReady
// The following properties are set by onReady as they live in account_data
private _allRoomsInHome = false;
private _enabledMetaSpaces: MetaSpace[] = [];

constructor() {
super(defaultDispatcher, {});
Expand Down Expand Up @@ -1042,6 +1043,8 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
const enabledMetaSpaces = SettingsStore.getValue("Spaces.enabledMetaSpaces");
this._enabledMetaSpaces = metaSpaceOrder.filter(k => enabledMetaSpaces[k]) as MetaSpace[];

this._allRoomsInHome = SettingsStore.getValue("Spaces.allRoomsInHome");

this.rebuildSpaceHierarchy(); // trigger an initial update

// restore selected state from last session if any and still valid
Expand Down