feat: Added keyboard shortcut (Ctrl/Cmd+,) for opening preferences

This commit is contained in:
Aman Harwara
2022-12-05 13:34:34 +05:30
parent 71e20f2a2f
commit 7c261af230
3 changed files with 20 additions and 1 deletions

View File

@@ -1,12 +1,23 @@
import { FunctionComponent } from 'react'
import { FunctionComponent, useEffect } from 'react'
import { observer } from 'mobx-react-lite'
import PreferencesView from './PreferencesView'
import { PreferencesViewWrapperProps } from './PreferencesViewWrapperProps'
import { useCommandService } from '../CommandProvider'
import { OPEN_PREFERENCES_COMMAND } from '@standardnotes/ui-services'
const PreferencesViewWrapper: FunctionComponent<PreferencesViewWrapperProps> = ({
viewControllerManager,
application,
}) => {
const commandService = useCommandService()
useEffect(() => {
return commandService.addCommandHandler({
command: OPEN_PREFERENCES_COMMAND,
onKeyDown: () => viewControllerManager.preferencesController.openPreferences(),
})
}, [commandService, viewControllerManager])
if (!viewControllerManager.preferencesController?.isOpen) {
return null
}