chore: fix modal close on escape

This commit is contained in:
Aman Harwara
2023-05-19 19:11:13 +05:30
parent 8f2cdc5839
commit d83e371022
21 changed files with 45 additions and 64 deletions

View File

@@ -7,8 +7,6 @@ import { PreferencesProps } from './PreferencesProps'
import { useAndroidBackHandler } from '@/NativeMobileWeb/useAndroidBackHandler'
import Modal, { ModalAction } from '../Modal/Modal'
import { classNames } from '@standardnotes/snjs'
import { useCommandService } from '../CommandProvider'
import { ESCAPE_COMMAND } from '@standardnotes/ui-services'
import { useAvailableSafeAreaPadding } from '@/Hooks/useSafeAreaPadding'
import { MutuallyExclusiveMediaQueryBreakpoints, useMediaQuery } from '@/Hooks/useMediaQuery'
import Icon from '../Icon/Icon'
@@ -20,8 +18,6 @@ const PreferencesView: FunctionComponent<PreferencesProps> = ({
userProvider,
mfaProvider,
}) => {
const commandService = useCommandService()
const menu = useMemo(
() => new PreferencesMenu(application, viewControllerManager.enableUnfinishedFeatures),
[viewControllerManager.enableUnfinishedFeatures, application],
@@ -47,16 +43,6 @@ const PreferencesView: FunctionComponent<PreferencesProps> = ({
}
}, [addAndroidBackHandler, closePreferences])
useEffect(() => {
return commandService.addCommandHandler({
command: ESCAPE_COMMAND,
onKeyDown: () => {
closePreferences()
return true
},
})
}, [commandService, closePreferences])
const { hasTopInset } = useAvailableSafeAreaPadding()
const modalActions = useMemo(