From 7c4d0ceddcde369b103b66c13ca053802eea7e7f Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 21 Apr 2023 09:54:27 -0400 Subject: [PATCH] Fix a crash when a call ends while you're in it (#10681) --- src/models/Call.ts | 1 + test/models/Call-test.ts | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/models/Call.ts b/src/models/Call.ts index d3b99db284..c78aed3a40 100644 --- a/src/models/Call.ts +++ b/src/models/Call.ts @@ -773,6 +773,7 @@ export class ElementCall extends Call { } public destroy(): void { + ActiveWidgetStore.instance.destroyPersistentWidget(this.widget.id, this.groupCall.room.roomId); WidgetStore.instance.removeVirtualWidget(this.widget.id, this.groupCall.room.roomId); this.off(CallEvent.Participants, this.onParticipants); this.groupCall.off(GroupCallEvent.ParticipantsChanged, this.onGroupCallParticipants); diff --git a/test/models/Call-test.ts b/test/models/Call-test.ts index da10098e53..43d26f0dbc 100644 --- a/test/models/Call-test.ts +++ b/test/models/Call-test.ts @@ -1050,6 +1050,12 @@ describe("ElementCall", () => { call.off(CallEvent.Destroy, onDestroy); }); + + it("clears widget persistence when destroyed", async () => { + const destroyPersistentWidgetSpy = jest.spyOn(ActiveWidgetStore.instance, "destroyPersistentWidget"); + call.destroy(); + expect(destroyPersistentWidgetSpy).toHaveBeenCalled(); + }); }); describe("instance in a video room", () => {