From 8e16427497dc1d0b288e889c4a4a72abbfdf5a7e Mon Sep 17 00:00:00 2001
From: Hailey <me@haileyok.com>
Date: Fri, 11 Oct 2024 16:42:43 -0700
Subject: 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
---
 src/state/shell/composer/useComposerKeyboardShortcut.tsx | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

(limited to 'src/state/shell/composer/useComposerKeyboardShortcut.tsx')

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,
+  ])
 }
-- 
cgit 1.4.1

