Skip to content

Commit bbf12a1

Browse files
fix: videoconf ringer not working after a temporary disconnection (#35330)
1 parent bc23e6f commit bbf12a1

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

.changeset/angry-colts-worry.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@rocket.chat/meteor': patch
3+
---
4+
5+
fixes an issue where videoconf calls could sometimes fail to ring an user after a temporary disconnection

apps/meteor/client/lib/VideoConfManager.ts

+12-9
Original file line numberDiff line numberDiff line change
@@ -305,17 +305,16 @@ export const VideoConfManager = new (class VideoConfManager extends Emitter<Vide
305305
public updateUser(): void {
306306
const userId = Meteor.userId();
307307

308-
if (this.userId === userId) {
309-
this.debugLog(`[VideoConf] Logged user has not changed, so we're not changing the hooks.`);
310-
return;
311-
}
312-
313-
this.debugLog(`[VideoConf] Logged user has changed.`);
308+
this.debugLog(`[VideoConf] Logged user or connection status has changed.`);
314309

315310
if (this.userId) {
316-
this.disconnect();
311+
this.disconnect(this.userId !== userId);
317312
}
318313

314+
if (!Meteor.status().connected || (userId && Meteor.loggingIn())) {
315+
this.debugLog(`[VideoConf] Connection lost or login process still pending, skipping user change.`);
316+
return;
317+
}
319318
if (userId) {
320319
this.connectUser(userId);
321320
}
@@ -458,12 +457,17 @@ export const VideoConfManager = new (class VideoConfManager extends Emitter<Vide
458457
sdk.rest.post('/v1/video-conference.cancel', { callId });
459458
}
460459

461-
private disconnect(): void {
460+
private disconnect(clearCalls = true): void {
462461
console.log(`[VideoConf] disconnecting user ${this.userId}`);
463462
for (const hook of this.hooks) {
464463
hook();
465464
}
466465
this.hooks = [];
466+
this.userId = undefined;
467+
468+
if (!clearCalls) {
469+
return;
470+
}
467471

468472
if (this.currentCallHandler) {
469473
clearInterval(this.currentCallHandler);
@@ -478,7 +482,6 @@ export const VideoConfManager = new (class VideoConfManager extends Emitter<Vide
478482
clearTimeout(call.acceptTimeout);
479483
}
480484
});
481-
this.userId = undefined;
482485
this.incomingDirectCalls.clear();
483486
this.dismissedCalls.clear();
484487
this.currentCallData = undefined;

0 commit comments

Comments
 (0)