Skip to content

Commit a798772

Browse files
committed
Unregister from the dispatcher in CallHandler
otherwise you end up getting multiple place_call dispatches if you place a call after logging in
1 parent 7998f79 commit a798772

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/CallHandler.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ function getRemoteAudioElement(): HTMLAudioElement {
118118
export default class CallHandler {
119119
private calls = new Map<string, MatrixCall>(); // roomId -> call
120120
private audioPromises = new Map<AudioID, Promise<void>>();
121+
private dispatcherRef: string;
121122

122123
static sharedInstance() {
123124
if (!window.mxCallHandler) {
@@ -128,7 +129,7 @@ export default class CallHandler {
128129
}
129130

130131
start() {
131-
dis.register(this.onAction);
132+
this.dispatcherRef = dis.register(this.onAction);
132133
// add empty handlers for media actions, otherwise the media keys
133134
// end up causing the audio elements with our ring/ringback etc
134135
// audio clips in to play.
@@ -151,6 +152,7 @@ export default class CallHandler {
151152
if (cli) {
152153
cli.removeListener('Call.incoming', this.onCallIncoming);
153154
}
155+
if (this.dispatcherRef) dis.unregister(this.dispatcherRef);
154156
}
155157

156158
private onCallIncoming = (call) => {

0 commit comments

Comments
 (0)