feat: when no users in room fetch data from firebase immediately
This commit is contained in:
parent
e340103250
commit
a2d371bf1d
@ -374,10 +374,30 @@ class Collab extends PureComponent<Props, CollabState> {
|
|||||||
}
|
}
|
||||||
this.onPauseCollaborationChange(PauseCollaborationState.SYNCED);
|
this.onPauseCollaborationChange(PauseCollaborationState.SYNCED);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Set timeout to fallback to fetch data from firebase
|
||||||
this.fallbackResumeTimeout = setTimeout(
|
this.fallbackResumeTimeout = setTimeout(
|
||||||
fallbackResumeHandler,
|
fallbackResumeHandler,
|
||||||
RESUME_FALLBACK_TIMEOUT,
|
RESUME_FALLBACK_TIMEOUT,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// When no users are in the room, we fallback to fetch data from firebase immediately and clear fallback timeout
|
||||||
|
this.portal.socket.on("first-in-room", () => {
|
||||||
|
if (this.portal.socket) {
|
||||||
|
this.portal.socket.off("first-in-room");
|
||||||
|
}
|
||||||
|
|
||||||
|
fallbackResumeHandler();
|
||||||
|
|
||||||
|
if (this.fallbackResumeTimeout) {
|
||||||
|
clearTimeout(this.fallbackResumeTimeout);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear pause timeout if exists
|
||||||
|
if (this.pauseTimeoutId) {
|
||||||
|
clearTimeout(this.pauseTimeoutId);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user