refactor: introduce pause method to socket service to preserve event listeners during idle disconnects
This commit is contained in:
@@ -44,7 +44,11 @@ export function PresenceProvider({ children }: { children: React.ReactNode }) {
|
||||
const disconnectForIdle = useCallback(() => {
|
||||
if (!isConnectedRef.current) return;
|
||||
isIdleRef.current = true;
|
||||
socketService.disconnect();
|
||||
// Use pause() instead of disconnect() so subscriber handlers
|
||||
// (useMessaging listeners) survive the reconnect. Otherwise the
|
||||
// user would have to refresh the page after returning from idle
|
||||
// to see new messages in real time again.
|
||||
socketService.pause();
|
||||
}, []);
|
||||
|
||||
// Track socket connection state
|
||||
|
||||
Reference in New Issue
Block a user