You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-08-07 21:23:00 +03:00
Store refactor: make it easier to test stores (#9290)
* refactor: convert RoomViewStore from flux Store to standard EventEmitter
Parts of a series of experimental changes to improve the design of stores.
* Use a gen5 store for RoomViewStore for now due to lock handling
* Revert "Use a gen5 store for RoomViewStore for now due to lock handling"
This reverts commit 1076af071d
.
* Add untilEmission and tweak untilDispatch; use it in RoomViewStore
* Add more RVS tests; remove custom room ID listener code and use EventEmitter
* Better comments
* Null guard `dis` as tests mock out `defaultDispatcher`
* Additional tests
This commit is contained in:
@@ -42,6 +42,7 @@ import { RightPanelPhases } from "../../../src/stores/right-panel/RightPanelStor
|
||||
import { LocalRoom, LocalRoomState } from "../../../src/models/LocalRoom";
|
||||
import { DirectoryMember } from "../../../src/utils/direct-messages";
|
||||
import { createDmLocalRoom } from "../../../src/utils/dm/createDmLocalRoom";
|
||||
import { UPDATE_EVENT } from "../../../src/stores/AsyncStore";
|
||||
|
||||
const RoomView = wrapInMatrixClientContext(_RoomView);
|
||||
|
||||
@@ -74,12 +75,13 @@ describe("RoomView", () => {
|
||||
const mountRoomView = async (): Promise<ReactWrapper> => {
|
||||
if (RoomViewStore.instance.getRoomId() !== room.roomId) {
|
||||
const switchedRoom = new Promise<void>(resolve => {
|
||||
const subscription = RoomViewStore.instance.addListener(() => {
|
||||
const subFn = () => {
|
||||
if (RoomViewStore.instance.getRoomId()) {
|
||||
subscription.remove();
|
||||
RoomViewStore.instance.off(UPDATE_EVENT, subFn);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
};
|
||||
RoomViewStore.instance.on(UPDATE_EVENT, subFn);
|
||||
});
|
||||
|
||||
defaultDispatcher.dispatch<ViewRoomPayload>({
|
||||
|
Reference in New Issue
Block a user