fix destroy condition
This commit is contained in:
@@ -354,15 +354,21 @@ export class RoomViewStore extends EventEmitter {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start a call if requested
|
// Start a call if requested and not already there
|
||||||
const currentRoomCall = this.state.roomId ? CallStore.instance.getCall(this.state.roomId) : null;
|
const currentRoomCall = payload.room_id ? CallStore.instance.getCall(payload.room_id) : null;
|
||||||
if (payload.view_call && room && !currentRoomCall) {
|
if (payload.view_call && room && !currentRoomCall) {
|
||||||
ElementCall.create(room, false);
|
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;
|
const prevRoomCall = this.state.roomId ? CallStore.instance.getCall(this.state.roomId) : null;
|
||||||
if (prevRoomCall && !prevRoomCall.connected) {
|
if (
|
||||||
currentRoomCall?.destroy();
|
// 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) {
|
if (SettingsStore.getValue("feature_sliding_sync") && this.state.roomId !== payload.room_id) {
|
||||||
|
|||||||
@@ -316,7 +316,6 @@ describe("RoomViewStore", function () {
|
|||||||
it("should display an error message when the room is unreachable via the roomId", async () => {
|
it("should display an error message when the room is unreachable via the roomId", async () => {
|
||||||
// When
|
// When
|
||||||
// View and wait for the room
|
// View and wait for the room
|
||||||
// jest.spyOn(WidgetStore).mockReturnValue({ getApps: () => [] } as unknown as void & WidgetStore);
|
|
||||||
dis.dispatch({ action: Action.ViewRoom, room_id: roomId });
|
dis.dispatch({ action: Action.ViewRoom, room_id: roomId });
|
||||||
await untilDispatch(Action.ActiveRoomChanged, dis);
|
await untilDispatch(Action.ActiveRoomChanged, dis);
|
||||||
// Generate error to display the expected error message
|
// Generate error to display the expected error message
|
||||||
|
|||||||
Reference in New Issue
Block a user