mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-03 10:53:42 -05:00
20 lines
683 B
TypeScript
20 lines
683 B
TypeScript
|
import { useEffect } from 'react'
|
||
|
import { useConnectionContext } from '@/features/ide-react/context/connection-context'
|
||
|
import { useModalsContext } from '@/features/ide-react/context/modals-context'
|
||
|
|
||
|
export const useConnectionState = () => {
|
||
|
const { connectionState } = useConnectionContext()
|
||
|
const { showLockEditorMessageModal } = useModalsContext()
|
||
|
|
||
|
// Show modal when editor is forcefully disconnected
|
||
|
useEffect(() => {
|
||
|
if (connectionState.forceDisconnected) {
|
||
|
showLockEditorMessageModal(connectionState.forcedDisconnectDelay)
|
||
|
}
|
||
|
}, [
|
||
|
connectionState.forceDisconnected,
|
||
|
connectionState.forcedDisconnectDelay,
|
||
|
showLockEditorMessageModal,
|
||
|
])
|
||
|
}
|