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
This commit is contained in:
Hailey
2024-10-11 16:42:43 -07:00
committed by GitHub
parent eaba658419
commit 8e16427497
3 changed files with 21 additions and 9 deletions
@@ -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,
])
}