message: Track restricted join rule support in the SpaceStore for sync access
diff: @@ -19,6 +19,8 @@ import { ListIteratee, Many, sortBy, throttle } from "lodash";
  import { EventType, RoomType } from "matrix-js-sdk/src/@types/event";
  import { Room } from "matrix-js-sdk/src/models/room";
  import { MatrixEvent } from "matrix-js-sdk/src/models/event";
  +import { JoinRule } from "matrix-js-sdk/src/@types/partials";
  +import { IRoomCapability } from "matrix-js-sdk/src/client";
  import { AsyncStoreWithClient } from "./AsyncStoreWithClient";
  import defaultDispatcher from "../dispatcher/dispatcher";
  @@ -45,7 +47,6 @@ import { _t } from "../languageHandler";
  import GenericToast from "../components/views/toasts/GenericToast";
  import Modal from "../Modal";
  import InfoDialog from "../components/views/dialogs/InfoDialog";
  -import { JoinRule } from "../../../matrix-js-sdk/src/@types/partials";
  type SpaceKey = string | symbol;
  @@ -115,6 +116,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
  private _suggestedRooms: ISuggestedRoom[] = [];
  private _invitedSpaces = new Set<Room>();
  private spaceOrderLocalEchoMap = new Map<string, string>();
  + private _restrictedJoinRuleSupport?: IRoomCapability;
  public get invitedSpaces(): Room[] {
  return Array.from(this._invitedSpaces);
  @@ -132,6 +134,10 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
  return this._suggestedRooms;
  }
  + public get restrictedJoinRuleSupport(): IRoomCapability {
  + return this._restrictedJoinRuleSupport;
  + }
  +
  /**
  * Sets the active space, updates room list filters,
  * optionally switches the user's room back to where they were when they last viewed that space.
  @@ -182,12 +188,10 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
  }
  // New in Spaces beta toast for Restricted Join Rule
  - (async () => {
  const lsKey = "mx_SpaceBeta_restrictedJoinRuleToastSeen";
  if (contextSwitch && space?.getJoinRule() === JoinRule.Invite && shouldShowSpaceSettings(space) &&
  - space.getJoinedMemberCount() > 1 && !localStorage.getItem(lsKey) /*&&
  - (await this.matrixClient.getCapabilities())
  - ?.["m.room_versions"]?.["org.matrix.msc3244.room_capabilities"]?.["restricted"]?.preferred*/
  + space.getJoinedMemberCount() > 1 && !localStorage.getItem(lsKey)
  + && this.restrictedJoinRuleSupport?.preferred
  ) {
  const toastKey = "restrictedjoinrule";
  ToastStore.sharedInstance().addOrReplaceToast({
  @@ -241,7 +245,6 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
  priority: 35,
  });
  }
  - })().then();
  if (space) {
  const suggestedRooms = await this.fetchSuggestedRooms(space);
  @@ -709,6 +712,11 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
  this.matrixClient.on("accountData", this.onAccountData);
  }
  + this.matrixClient.getCapabilities().then(capabilities => {
  + this._restrictedJoinRuleSupport = capabilities
  + ?.["m.room_versions"]?.["org.matrix.msc3244.room_capabilities"]?.["restricted"];
  + });
  +
  await this.onSpaceUpdate(); // trigger an initial update
  // restore selected state from last session if any and still valid
  