Skip to content

Commit

Permalink
Extract consts
Browse files Browse the repository at this point in the history
  • Loading branch information
gbalint committed Jan 29, 2024
1 parent e8fb2a2 commit fc5d6fd
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions editor/src/core/shared/multiplayer-hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ export function useMonitorConnection() {
}, [updateLastSeen, cleanupInactive])
}

const ReconnectingLiveblocksToastId = 'reconnecting-liveblocks'
const LostLiveblocksConnectionToastId = 'lost-liveblocks-connection'

export function useLiveblocksConnectionListener() {
const dispatch = useDispatch()
const loggedIn = useIsLoggedIn()
Expand All @@ -270,23 +273,33 @@ export function useLiveblocksConnectionListener() {
if (loggedIn) {
dispatch([
showToast(
notice('Reconnecting to other users...', 'WARNING', true, 'reconnecting-liveblocks'),
notice(
'Reconnecting to other users...',
'WARNING',
true,
ReconnectingLiveblocksToastId,
),
),
])
}
break

case 'restored':
dispatch([
removeToast('lost-liveblocks-connection'),
removeToast('reconnecting-liveblocks'),
removeToast(LostLiveblocksConnectionToastId),
removeToast(ReconnectingLiveblocksToastId),
])
break

case 'failed':
if (loggedIn) {
showToast(
notice('Lost connection to other users', 'ERROR', true, 'lost-liveblocks-connection'),
notice(
'Lost connection to other users',
'ERROR',
true,
LostLiveblocksConnectionToastId,
),
)
}
break
Expand Down

0 comments on commit fc5d6fd

Please sign in to comment.