fix destroy condition

This commit is contained in:
Timo
2025-02-11 14:22:26 +01:00
parent b7b8719171
commit 471712cbf0
2 changed files with 11 additions and 6 deletions

View File

@@ -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) {

View File

@@ -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