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

Commit

Permalink
Fill viewRoomOpts in viewRoom
Browse files Browse the repository at this point in the history
  • Loading branch information
florianduros committed Dec 18, 2023
1 parent 6398bea commit 5b5926d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 34 deletions.
3 changes: 1 addition & 2 deletions src/components/structures/RoomView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1409,8 +1409,6 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
tombstone: this.getRoomTombstone(room),
liveTimeline: room.getLiveTimeline(),
});

dis.dispatch<ActionPayload>({ action: Action.RoomLoaded });
};

private onRoomTimelineReset = (room?: Room): void => {
Expand Down Expand Up @@ -1672,6 +1670,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
this.state.initialEventId === eventId
) {
debuglog("Removing scroll_into_view flag from initial event");
debugger;

Check failure on line 1673 in src/components/structures/RoomView.tsx

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected 'debugger' statement
dis.dispatch<ViewRoomPayload>({
action: Action.ViewRoom,
room_id: this.getRoomId(),
Expand Down
5 changes: 0 additions & 5 deletions src/dispatcher/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,6 @@ export enum Action {
*/
OpenSpotlight = "open_spotlight",

/**
* Fired when the room loaded.
*/
RoomLoaded = "room_loaded",

/**
* Opens right panel with 3pid invite information
*/
Expand Down
19 changes: 4 additions & 15 deletions src/stores/RoomViewStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,6 @@ export class RoomViewStore extends EventEmitter {
this.cancelAskToJoin(payload as CancelAskToJoinPayload);
break;
}
case Action.RoomLoaded: {
this.setViewRoomOpts();
break;
}
}
}

Expand Down Expand Up @@ -443,6 +439,9 @@ export class RoomViewStore extends EventEmitter {
return;
}

const viewRoomOpts: ViewRoomOpts = { buttons: [] };
ModuleRunner.instance.invoke(RoomViewLifecycle.ViewRoom, viewRoomOpts, this.getRoomId());

const newState: Partial<State> = {
roomId: payload.room_id,
roomAlias: payload.room_alias ?? null,
Expand All @@ -464,6 +463,7 @@ export class RoomViewStore extends EventEmitter {
(payload.room_id === this.state.roomId
? this.state.viewingCall
: CallStore.instance.getActiveCall(payload.room_id) !== null),
viewRoomOpts,
};

// Allow being given an event to be replied to when switching rooms but sanity check its for this room
Expand Down Expand Up @@ -823,15 +823,4 @@ export class RoomViewStore extends EventEmitter {
public getViewRoomOpts(): ViewRoomOpts {
return this.state.viewRoomOpts;
}

/**
* Invokes the view room lifecycle to set the view room options.
*
* @returns {void}
*/
private setViewRoomOpts(): void {
const viewRoomOpts: ViewRoomOpts = { buttons: [] };
ModuleRunner.instance.invoke(RoomViewLifecycle.ViewRoom, viewRoomOpts, this.getRoomId());
this.setState({ viewRoomOpts });
}
}
6 changes: 0 additions & 6 deletions test/components/structures/RoomView-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -585,10 +585,4 @@ describe("RoomView", () => {
expect(dis.dispatch).toHaveBeenCalledWith({ action: "cancel_ask_to_join", roomId: room.roomId });
});
});

it("fires Action.RoomLoaded", async () => {
jest.spyOn(dis, "dispatch");
await mountRoomView();
expect(dis.dispatch).toHaveBeenCalledWith({ action: Action.RoomLoaded });
});
});
10 changes: 4 additions & 6 deletions test/stores/RoomViewStore-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,6 @@ describe("RoomViewStore", function () {
await untilDispatch(Action.CancelAskToJoin, dis);
};

const dispatchRoomLoaded = async () => {
dis.dispatch({ action: Action.RoomLoaded });
await untilDispatch(Action.RoomLoaded, dis);
};

let roomViewStore: RoomViewStore;
let slidingSyncManager: SlidingSyncManager;
let dis: MatrixDispatcher;
Expand Down Expand Up @@ -598,7 +593,10 @@ describe("RoomViewStore", function () {
opts.buttons = buttons;
}
});
await dispatchRoomLoaded();

dis.dispatch({ action: Action.ViewRoom, room_id: roomId });
await untilDispatch(Action.ViewRoom, dis);

expect(roomViewStore.getViewRoomOpts()).toEqual({ buttons });

Check warning on line 600 in test/stores/RoomViewStore-test.ts

View workflow job for this annotation

GitHub Actions / Jest

RETRY 1: RoomViewStore › Action.RoomLoaded › updates viewRoomOpts

expect(received).toEqual(expected) // deep equality - Expected - 8 + Received + 1 Object { - "buttons": Array [ - Object { - "icon": "test-icon", - "id": "test-id", - "label": [Function label], - "onClick": [Function onClick], - }, - ], + "buttons": Array [], } at Object.toEqual (test/stores/RoomViewStore-test.ts:600:53)

Check warning on line 600 in test/stores/RoomViewStore-test.ts

View workflow job for this annotation

GitHub Actions / Jest

RETRY 2: RoomViewStore › Action.RoomLoaded › updates viewRoomOpts

expect(received).toEqual(expected) // deep equality - Expected - 8 + Received + 1 Object { - "buttons": Array [ - Object { - "icon": "test-icon", - "id": "test-id", - "label": [Function label], - "onClick": [Function onClick], - }, - ], + "buttons": Array [], } at Object.toEqual (test/stores/RoomViewStore-test.ts:600:53)

Check failure on line 600 in test/stores/RoomViewStore-test.ts

View workflow job for this annotation

GitHub Actions / Jest

RoomViewStore › Action.RoomLoaded › updates viewRoomOpts

expect(received).toEqual(expected) // deep equality - Expected - 8 + Received + 1 Object { - "buttons": Array [ - Object { - "icon": "test-icon", - "id": "test-id", - "label": [Function label], - "onClick": [Function onClick], - }, - ], + "buttons": Array [], } at Object.toEqual (test/stores/RoomViewStore-test.ts:600:53)
});
});
Expand Down

0 comments on commit 5b5926d

Please sign in to comment.