feat: when no users in room fetch data from firebase immediately

This commit is contained in:
Arnošt Pleskot 2023-06-19 14:53:49 +02:00
parent e340103250
commit a2d371bf1d
No known key found for this signature in database

View File

@ -374,10 +374,30 @@ class Collab extends PureComponent<Props, CollabState> {
}
this.onPauseCollaborationChange(PauseCollaborationState.SYNCED);
};
// Set timeout to fallback to fetch data from firebase
this.fallbackResumeTimeout = setTimeout(
fallbackResumeHandler,
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;