Skip to content

Commit

Permalink
fix destroy condition
Browse files Browse the repository at this point in the history
  • Loading branch information
toger5 committed Feb 11, 2025
1 parent b7b8719 commit 471712c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
16 changes: 11 additions & 5 deletions src/stores/RoomViewStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,21 @@ export class RoomViewStore extends EventEmitter {
});
}

// Start a call if requested
const currentRoomCall = this.state.roomId ? CallStore.instance.getCall(this.state.roomId) : null;
// Start a call if requested and not already there
const currentRoomCall = payload.room_id ? CallStore.instance.getCall(payload.room_id) : null;
if (payload.view_call && room && !currentRoomCall) {
ElementCall.create(room, false);
}
// Destroy the call when leaving call view
// Destroy all calls that are not connected when dispatching to a new room id.
const prevRoomCall = this.state.roomId ? CallStore.instance.getCall(this.state.roomId) : null;
if (prevRoomCall && !prevRoomCall.connected) {
currentRoomCall?.destroy();
if (
// not looking at prevRoomCall anymore
(!payload.view_call || payload.room_id !== this.state.roomId) &&
// not connected to the previous call anymore
prevRoomCall &&
!prevRoomCall.connected
) {
prevRoomCall?.destroy();
}

if (SettingsStore.getValue("feature_sliding_sync") && this.state.roomId !== payload.room_id) {
Expand Down
1 change: 0 additions & 1 deletion test/unit-tests/stores/RoomViewStore-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ describe("RoomViewStore", function () {
it("should display an error message when the room is unreachable via the roomId", async () => {
// When
// View and wait for the room
// jest.spyOn(WidgetStore).mockReturnValue({ getApps: () => [] } as unknown as void & WidgetStore);
dis.dispatch({ action: Action.ViewRoom, room_id: roomId });
await untilDispatch(Action.ActiveRoomChanged, dis);
// Generate error to display the expected error message
Expand Down

0 comments on commit 471712c

Please sign in to comment.