Rename RoomListStore2 class name

We use `RoomListStore` as a singleton, and don't want the ugly `2` at the end of the actual store instance, so here we rename it to something half-decent.
This commit is contained in:
Travis Ralston 2020-07-17 15:10:30 -06:00
parent 1f9c07861e
commit 209a5d2220
4 changed files with 15 additions and 12 deletions

View file

@ -20,7 +20,7 @@ import { IMatrixClientPeg } from "../MatrixClientPeg";
import ToastStore from "../stores/ToastStore"; import ToastStore from "../stores/ToastStore";
import DeviceListener from "../DeviceListener"; import DeviceListener from "../DeviceListener";
import RebrandListener from "../RebrandListener"; import RebrandListener from "../RebrandListener";
import { RoomListStore2 } from "../stores/room-list/RoomListStore2"; import { RoomListStoreClass } from "../stores/room-list/RoomListStore2";
import { PlatformPeg } from "../PlatformPeg"; import { PlatformPeg } from "../PlatformPeg";
import RoomListLayoutStore from "../stores/room-list/RoomListLayoutStore"; import RoomListLayoutStore from "../stores/room-list/RoomListLayoutStore";
import {IntegrationManagers} from "../integrations/IntegrationManagers"; import {IntegrationManagers} from "../integrations/IntegrationManagers";
@ -37,7 +37,7 @@ declare global {
mx_ToastStore: ToastStore; mx_ToastStore: ToastStore;
mx_DeviceListener: DeviceListener; mx_DeviceListener: DeviceListener;
mx_RebrandListener: RebrandListener; mx_RebrandListener: RebrandListener;
mx_RoomListStore2: RoomListStore2; mx_RoomListStore: RoomListStoreClass;
mx_RoomListLayoutStore: RoomListLayoutStore; mx_RoomListLayoutStore: RoomListLayoutStore;
mxPlatformPeg: PlatformPeg; mxPlatformPeg: PlatformPeg;
mxIntegrationManagers: typeof IntegrationManagers; mxIntegrationManagers: typeof IntegrationManagers;

View file

@ -44,7 +44,7 @@ interface IState {
*/ */
export const LISTS_UPDATE_EVENT = "lists_update"; export const LISTS_UPDATE_EVENT = "lists_update";
export class RoomListStore2 extends AsyncStoreWithClient<ActionPayload> { export class RoomListStoreClass extends AsyncStoreWithClient<ActionPayload> {
/** /**
* Set to true if you're running tests on the store. Should not be touched in * Set to true if you're running tests on the store. Should not be touched in
* any other environment. * any other environment.
@ -175,7 +175,7 @@ export class RoomListStore2 extends AsyncStoreWithClient<ActionPayload> {
protected async onAction(payload: ActionPayload) { protected async onAction(payload: ActionPayload) {
// When we're running tests we can't reliably use setImmediate out of timing concerns. // When we're running tests we can't reliably use setImmediate out of timing concerns.
// As such, we use a more synchronous model. // As such, we use a more synchronous model.
if (RoomListStore2.TEST_MODE) { if (RoomListStoreClass.TEST_MODE) {
await this.onDispatchAsync(payload); await this.onDispatchAsync(payload);
return; return;
} }
@ -608,15 +608,15 @@ export class RoomListStore2 extends AsyncStoreWithClient<ActionPayload> {
} }
export default class RoomListStore { export default class RoomListStore {
private static internalInstance: RoomListStore2; private static internalInstance: RoomListStoreClass;
public static get instance(): RoomListStore2 { public static get instance(): RoomListStoreClass {
if (!RoomListStore.internalInstance) { if (!RoomListStore.internalInstance) {
RoomListStore.internalInstance = new RoomListStore2(); RoomListStore.internalInstance = new RoomListStoreClass();
} }
return RoomListStore.internalInstance; return RoomListStore.internalInstance;
} }
} }
window.mx_RoomListStore2 = RoomListStore.instance; window.mx_RoomListStore = RoomListStore.instance;

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import { RoomListStore2 } from "./RoomListStore2"; import { RoomListStoreClass } from "./RoomListStore2";
import TagOrderStore from "../TagOrderStore"; import TagOrderStore from "../TagOrderStore";
import { CommunityFilterCondition } from "./filters/CommunityFilterCondition"; import { CommunityFilterCondition } from "./filters/CommunityFilterCondition";
import { arrayDiff, arrayHasDiff } from "../../utils/arrays"; import { arrayDiff, arrayHasDiff } from "../../utils/arrays";
@ -26,7 +26,7 @@ export class TagWatcher {
// TODO: Support custom tags, somehow: https://github.com/vector-im/riot-web/issues/14091 // TODO: Support custom tags, somehow: https://github.com/vector-im/riot-web/issues/14091
private filters = new Map<string, CommunityFilterCondition>(); private filters = new Map<string, CommunityFilterCondition>();
constructor(private store: RoomListStore2) { constructor(private store: RoomListStoreClass) {
TagOrderStore.addListener(this.onTagsUpdated); TagOrderStore.addListener(this.onTagsUpdated);
} }

View file

@ -14,7 +14,10 @@ import GroupStore from '../../../../src/stores/GroupStore.js';
import { MatrixClient, Room, RoomMember } from 'matrix-js-sdk'; import { MatrixClient, Room, RoomMember } from 'matrix-js-sdk';
import {DefaultTagID} from "../../../../src/stores/room-list/models"; import {DefaultTagID} from "../../../../src/stores/room-list/models";
import RoomListStore, {LISTS_UPDATE_EVENT, RoomListStore2} from "../../../../src/stores/room-list/RoomListStore2"; import RoomListStore, {
LISTS_UPDATE_EVENT,
RoomListStoreClass
} from "../../../../src/stores/room-list/RoomListStore2";
import RoomListLayoutStore from "../../../../src/stores/room-list/RoomListLayoutStore"; import RoomListLayoutStore from "../../../../src/stores/room-list/RoomListLayoutStore";
function generateRoomId() { function generateRoomId() {
@ -49,7 +52,7 @@ describe('RoomList', () => {
let myOtherMember; let myOtherMember;
beforeEach(async function(done) { beforeEach(async function(done) {
RoomListStore2.TEST_MODE = true; RoomListStoreClass.TEST_MODE = true;
TestUtils.stubClient(); TestUtils.stubClient();
client = MatrixClientPeg.get(); client = MatrixClientPeg.get();