mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
23593f8650
* Defer script loading * Refactor loading * Wait for project:joined * Only mount IdePage once everything has connected * Add useConnectionState hook and comments * Remove placeholder components * Move props into EditorAndSidebar * Move props into MainLayout * Tidy editor and sidebar components * Lazy-load the symbol palette pane and separate the loading pane GitOrigin-RevId: 4b721a06d6aba0ae0ec91768e6a6e29cf15e2083
19 lines
683 B
TypeScript
19 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,
|
|
])
|
|
}
|