diff --git a/src/components/structures/UserMenu.tsx b/src/components/structures/UserMenu.tsx
index a583af2603..baa5d661a3 100644
--- a/src/components/structures/UserMenu.tsx
+++ b/src/components/structures/UserMenu.tsx
@@ -218,7 +218,7 @@ export default class UserMenu extends React.Component {
// way the right panel is structured makes this exceedingly difficult. Instead, we'll
// switch to the general room and open the member list there as it should be in sync
// anyways.
- const chat = CommunityPrototypeStore.instance.getGeneralChat(TagOrderStore.getSelectedPrototypeTag());
+ const chat = CommunityPrototypeStore.instance.getSelectedCommunityGeneralChat();
if (chat) {
dis.dispatch({
action: 'view_room',
@@ -239,7 +239,7 @@ export default class UserMenu extends React.Component {
ev.preventDefault();
ev.stopPropagation();
- showCommunityInviteDialog(TagOrderStore.getSelectedPrototypeTag());
+ showCommunityInviteDialog(CommunityPrototypeStore.instance.getSelectedCommunityId());
this.setState({contextMenuPosition: null}); // also close the menu
};
diff --git a/src/components/views/dialogs/CreateRoomDialog.js b/src/components/views/dialogs/CreateRoomDialog.js
index bdd3de07c0..5d370af341 100644
--- a/src/components/views/dialogs/CreateRoomDialog.js
+++ b/src/components/views/dialogs/CreateRoomDialog.js
@@ -25,7 +25,6 @@ import { _t } from '../../../languageHandler';
import {MatrixClientPeg} from '../../../MatrixClientPeg';
import {Key} from "../../../Keyboard";
import {privateShouldBeEncrypted} from "../../../createRoom";
-import TagOrderStore from "../../../stores/TagOrderStore";
import {CommunityPrototypeStore} from "../../../stores/CommunityPrototypeStore";
export default createReactClass({
@@ -72,8 +71,8 @@ export default createReactClass({
opts.encryption = this.state.isEncrypted;
}
- if (TagOrderStore.getSelectedPrototypeTag()) {
- opts.associatedWithCommunity = TagOrderStore.getSelectedPrototypeTag();
+ if (CommunityPrototypeStore.instance.getSelectedCommunityId()) {
+ opts.associatedWithCommunity = CommunityPrototypeStore.instance.getSelectedCommunityId();
}
return opts;
@@ -198,7 +197,7 @@ export default createReactClass({
"Private rooms can be found and joined by invitation only. Public rooms can be " +
"found and joined by anyone.",
)}
;
- if (TagOrderStore.getSelectedPrototypeTag()) {
+ if (CommunityPrototypeStore.instance.getSelectedCommunityId()) {
publicPrivateLabel = {_t(
"Private rooms can be found and joined by invitation only. Public rooms can be " +
"found and joined by anyone in this community.",
@@ -239,7 +238,7 @@ export default createReactClass({
}
let title = this.state.isPublic ? _t('Create a public room') : _t('Create a private room');
- if (TagOrderStore.getSelectedPrototypeTag()) {
+ if (CommunityPrototypeStore.instance.getSelectedCommunityId()) {
const name = CommunityPrototypeStore.instance.getSelectedCommunityName();
title = _t("Create a room in %(communityName)s", {communityName: name});
}
diff --git a/src/components/views/dialogs/InviteDialog.js b/src/components/views/dialogs/InviteDialog.js
index c2fd7e5b0e..80d8f1fc2c 100644
--- a/src/components/views/dialogs/InviteDialog.js
+++ b/src/components/views/dialogs/InviteDialog.js
@@ -37,7 +37,6 @@ import {Key} from "../../../Keyboard";
import {Action} from "../../../dispatcher/actions";
import {DefaultTagID} from "../../../stores/room-list/models";
import RoomListStore from "../../../stores/room-list/RoomListStore";
-import TagOrderStore from "../../../stores/TagOrderStore";
import {CommunityPrototypeStore} from "../../../stores/CommunityPrototypeStore";
// we have a number of types defined from the Matrix spec which can't reasonably be altered here.
@@ -913,7 +912,7 @@ export default class InviteDialog extends React.PureComponent {
_onCommunityInviteClick = (e) => {
this.props.onFinished();
- showCommunityInviteDialog(TagOrderStore.getSelectedPrototypeTag());
+ showCommunityInviteDialog(CommunityPrototypeStore.instance.getSelectedCommunityId());
};
_renderSection(kind: "recents"|"suggestions") {
@@ -924,8 +923,8 @@ export default class InviteDialog extends React.PureComponent {
let sectionName = kind === 'recents' ? _t("Recent Conversations") : _t("Suggestions");
let sectionSubname = null;
- if (kind === 'suggestions' && TagOrderStore.getSelectedPrototypeTag()) {
- const communityName = CommunityPrototypeStore.instance.getCommunityName(TagOrderStore.getSelectedPrototypeTag());
+ if (kind === 'suggestions' && CommunityPrototypeStore.instance.getSelectedCommunityId()) {
+ const communityName = CommunityPrototypeStore.instance.getSelectedCommunityName();
sectionSubname = _t("May include members not in %(communityName)s", {communityName});
}
@@ -1097,7 +1096,7 @@ export default class InviteDialog extends React.PureComponent {
return {userId};
}},
);
- if (TagOrderStore.getSelectedPrototypeTag()) {
+ if (CommunityPrototypeStore.instance.getSelectedCommunityId()) {
const communityName = CommunityPrototypeStore.instance.getSelectedCommunityName();
helpText = _t(
"Start a conversation with someone using their name, username (like ) or email address. " +
diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js
index 06ce8ddda8..15b629921c 100644
--- a/src/components/views/rooms/MemberList.js
+++ b/src/components/views/rooms/MemberList.js
@@ -27,7 +27,6 @@ import rate_limited_func from "../../../ratelimitedfunc";
import {MatrixClientPeg} from "../../../MatrixClientPeg";
import * as sdk from "../../../index";
import CallHandler from "../../../CallHandler";
-import TagOrderStore from "../../../stores/TagOrderStore";
import {CommunityPrototypeStore} from "../../../stores/CommunityPrototypeStore";
const INITIAL_LOAD_NUM_MEMBERS = 30;
@@ -467,12 +466,9 @@ export default createReactClass({
}
let inviteButtonText = _t("Invite to this room");
- const communityId = TagOrderStore.getSelectedPrototypeTag();
- if (communityId) {
- const chat = CommunityPrototypeStore.instance.getGeneralChat(communityId);
- if (chat && chat.roomId === this.props.roomId) {
- inviteButtonText = _t("Invite to this community");
- }
+ const chat = CommunityPrototypeStore.instance.getSelectedCommunityGeneralChat();
+ if (chat && chat.roomId === this.props.roomId) {
+ inviteButtonText = _t("Invite to this community");
}
const AccessibleButton = sdk.getComponent("elements.AccessibleButton");
diff --git a/src/components/views/rooms/RoomList.tsx b/src/components/views/rooms/RoomList.tsx
index 92c5982276..72e016d8e7 100644
--- a/src/components/views/rooms/RoomList.tsx
+++ b/src/components/views/rooms/RoomList.tsx
@@ -45,7 +45,7 @@ import { arrayFastClone, arrayHasDiff } from "../../../utils/arrays";
import { objectShallowClone, objectWithOnly } from "../../../utils/objects";
import { IconizedContextMenuOption, IconizedContextMenuOptionList } from "../context_menus/IconizedContextMenu";
import AccessibleButton from "../elements/AccessibleButton";
-import TagOrderStore from "../../../stores/TagOrderStore";
+import { CommunityPrototypeStore } from "../../../stores/CommunityPrototypeStore";
interface IProps {
onKeyDown: (ev: React.KeyboardEvent) => void;
@@ -130,7 +130,7 @@ const TAG_AESTHETICS: {
}}
/>
{
return CommunityPrototypeStore.internalInstance;
}
+ public getSelectedCommunityId(): string {
+ if (SettingsStore.getValue("feature_communities_v2_prototypes")) {
+ return TagOrderStore.getSelectedTags()[0];
+ }
+ return null; // no selection as far as this function is concerned
+ }
+
public getSelectedCommunityName(): string {
- return CommunityPrototypeStore.instance.getCommunityName(TagOrderStore.getSelectedPrototypeTag());
+ return CommunityPrototypeStore.instance.getCommunityName(this.getSelectedCommunityId());
+ }
+
+ public getSelectedCommunityGeneralChat(): Room {
+ const communityId = this.getSelectedCommunityId();
+ if (communityId) {
+ return this.getGeneralChat(communityId);
+ }
}
public getCommunityName(communityId: string): string {
diff --git a/src/stores/TagOrderStore.js b/src/stores/TagOrderStore.js
index 6651d207a1..3dfdc5feaf 100644
--- a/src/stores/TagOrderStore.js
+++ b/src/stores/TagOrderStore.js
@@ -286,13 +286,6 @@ class TagOrderStore extends Store {
getSelectedTags() {
return this._state.selectedTags;
}
-
- getSelectedPrototypeTag() {
- if (SettingsStore.getValue("feature_communities_v2_prototypes")) {
- return this.getSelectedTags()[0];
- }
- return null; // no selection as far as this function is concerned
- }
}
if (global.singletonTagOrderStore === undefined) {