about summary refs log tree commit diff
path: root/src/state/shell/composer/useComposerKeyboardShortcut.tsx
diff options
context:
space:
mode:
authorHailey <me@haileyok.com>2024-10-11 16:42:43 -0700
committerGitHub <noreply@github.com>2024-10-11 16:42:43 -0700
commit8e16427497dc1d0b288e889c4a4a72abbfdf5a7e (patch)
treee0c42553ccd5a09f36904d9a1f5c1e86fa89b61f /src/state/shell/composer/useComposerKeyboardShortcut.tsx
parenteaba6584198eac50e18cdaaa0fb41ac601990519 (diff)
downloadvoidsky-8e16427497dc1d0b288e889c4a4a72abbfdf5a7e.tar.zst
Move composer open shortcut to shell (#5723)
* move composer shortcut hook

* put intent handler in same place

* dont allow shortcuts if no session

* revert change
Diffstat (limited to 'src/state/shell/composer/useComposerKeyboardShortcut.tsx')
-rw-r--r--src/state/shell/composer/useComposerKeyboardShortcut.tsx15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/state/shell/composer/useComposerKeyboardShortcut.tsx b/src/state/shell/composer/useComposerKeyboardShortcut.tsx
index 01306e36e..cfec5c445 100644
--- a/src/state/shell/composer/useComposerKeyboardShortcut.tsx
+++ b/src/state/shell/composer/useComposerKeyboardShortcut.tsx
@@ -3,6 +3,7 @@ import React from 'react'
 import {useDialogStateContext} from '#/state/dialogs'
 import {useLightbox} from '#/state/lightbox'
 import {useModals} from '#/state/modals'
+import {useSession} from '#/state/session'
 import {useIsDrawerOpen} from '#/state/shell/drawer-open'
 import {useComposerControls} from './'
 
@@ -43,8 +44,13 @@ export function useComposerKeyboardShortcut() {
   const {isModalActive} = useModals()
   const {activeLightbox} = useLightbox()
   const isDrawerOpen = useIsDrawerOpen()
+  const {hasSession} = useSession()
 
   React.useEffect(() => {
+    if (!hasSession) {
+      return
+    }
+
     function handler(event: KeyboardEvent) {
       if (shouldIgnore(event)) return
       if (
@@ -60,5 +66,12 @@ export function useComposerKeyboardShortcut() {
     }
     document.addEventListener('keydown', handler)
     return () => document.removeEventListener('keydown', handler)
-  }, [openComposer, isModalActive, openDialogs, activeLightbox, isDrawerOpen])
+  }, [
+    openComposer,
+    isModalActive,
+    openDialogs,
+    activeLightbox,
+    isDrawerOpen,
+    hasSession,
+  ])
 }