use-connection-state.ts 683 B

12345678910111213141516171819
  1. import { useEffect } from 'react'
  2. import { useConnectionContext } from '@/features/ide-react/context/connection-context'
  3. import { useModalsContext } from '@/features/ide-react/context/modals-context'
  4. export const useConnectionState = () => {
  5. const { connectionState } = useConnectionContext()
  6. const { showLockEditorMessageModal } = useModalsContext()
  7. // Show modal when editor is forcefully disconnected
  8. useEffect(() => {
  9. if (connectionState.forceDisconnected) {
  10. showLockEditorMessageModal(connectionState.forcedDisconnectDelay)
  11. }
  12. }, [
  13. connectionState.forceDisconnected,
  14. connectionState.forcedDisconnectDelay,
  15. showLockEditorMessageModal,
  16. ])
  17. }