From 38f36aaa3c24912aeb954110b5b96e01d843a029 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Fri, 8 Jul 2022 14:59:50 +0200 Subject: [PATCH] =?UTF-8?q?Hotkey=20`=E2=8C=98+,`=20for=20settings=20on=20?= =?UTF-8?q?macOS=20PWA=20(#1913)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/left/LeftColumn.tsx | 12 +++++++++--- src/components/left/main/ChatList.tsx | 4 ++-- src/components/left/main/LeftMainHeader.tsx | 2 +- src/components/middle/HeaderActions.tsx | 2 +- .../middle/hooks/useCopySelectedMessages.ts | 2 +- src/hooks/useNativeCopySelectedMessages.ts | 2 +- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/components/left/LeftColumn.tsx b/src/components/left/LeftColumn.tsx index e834e200d..af5a6d113 100644 --- a/src/components/left/LeftColumn.tsx +++ b/src/components/left/LeftColumn.tsx @@ -6,7 +6,7 @@ import { getActions, withGlobal } from '../../global'; import { LeftColumnContent, SettingsScreens } from '../../types'; -import { LAYERS_ANIMATION_NAME } from '../../util/environment'; +import { IS_MAC_OS, IS_PWA, LAYERS_ANIMATION_NAME } from '../../util/environment'; import captureEscKeyListener from '../../util/captureEscKeyListener'; import useFoldersReducer from '../../hooks/reducers/useFoldersReducer'; import { useResize } from '../../hooks/useResize'; @@ -321,9 +321,15 @@ const LeftColumn: FC = ({ openChat({ id: currentUserId }); }, [currentUserId, openChat]); + const handleHotkeySettings = useCallback((e: KeyboardEvent) => { + e.preventDefault(); + setContent(LeftColumnContent.Settings); + }, []); + useHotkeys({ - 'mod+shift+F': handleHotkeySearch, - 'mod+shift+S': handleHotkeySavedMessages, + 'Mod+Shift+F': handleHotkeySearch, + 'Mod+Shift+S': handleHotkeySavedMessages, + ...(IS_MAC_OS && IS_PWA && { 'Mod+,': handleHotkeySettings }), }); useEffect(() => { diff --git a/src/components/left/main/ChatList.tsx b/src/components/left/main/ChatList.tsx index bb248c167..58da4dc3c 100644 --- a/src/components/left/main/ChatList.tsx +++ b/src/components/left/main/ChatList.tsx @@ -76,11 +76,11 @@ const ChatList: FC = ({ // Support + to navigate between chats useHotkeys(isActive && orderedIds?.length ? { - 'alt+ArrowUp': (e: KeyboardEvent) => { + 'Alt+ArrowUp': (e: KeyboardEvent) => { e.preventDefault(); openNextChat({ targetIndexDelta: -1, orderedIds }); }, - 'alt+ArrowDown': (e: KeyboardEvent) => { + 'Alt+ArrowDown': (e: KeyboardEvent) => { e.preventDefault(); openNextChat({ targetIndexDelta: 1, orderedIds }); }, diff --git a/src/components/left/main/LeftMainHeader.tsx b/src/components/left/main/LeftMainHeader.tsx index 2321bd54b..5e6804ed5 100644 --- a/src/components/left/main/LeftMainHeader.tsx +++ b/src/components/left/main/LeftMainHeader.tsx @@ -149,7 +149,7 @@ const LeftMainHeader: FC = ({ 'Ctrl+Shift+L': handleLockScreenHotkey, 'Alt+Shift+L': handleLockScreenHotkey, 'Meta+Shift+L': handleLockScreenHotkey, - ...(IS_PWA && { 'Meta+L': handleLockScreenHotkey }), + ...(IS_PWA && { 'Mod+L': handleLockScreenHotkey }), }); const withOtherVersions = window.location.hostname === PRODUCTION_HOSTNAME || IS_TEST; diff --git a/src/components/middle/HeaderActions.tsx b/src/components/middle/HeaderActions.tsx index eaa31b95d..a543803a0 100644 --- a/src/components/middle/HeaderActions.tsx +++ b/src/components/middle/HeaderActions.tsx @@ -153,7 +153,7 @@ const HeaderActions: FC = ({ }, [canSearch, handleSearchClick]); useHotkeys({ - 'Meta+F': handleHotkeySearchClick, + 'Mod+F': handleHotkeySearchClick, }); const lang = useLang(); diff --git a/src/components/middle/hooks/useCopySelectedMessages.ts b/src/components/middle/hooks/useCopySelectedMessages.ts index d9406efc6..91d17f17b 100644 --- a/src/components/middle/hooks/useCopySelectedMessages.ts +++ b/src/components/middle/hooks/useCopySelectedMessages.ts @@ -10,7 +10,7 @@ const useCopySelectedMessages = (isActive: boolean, copySelectedMessages: NoneTo copySelectedMessages(); } - useHotkeys({ 'Meta+C': handleCopy }); + useHotkeys({ 'Mod+C': handleCopy }); }; export default useCopySelectedMessages; diff --git a/src/hooks/useNativeCopySelectedMessages.ts b/src/hooks/useNativeCopySelectedMessages.ts index 9127e2fc8..5379989c4 100644 --- a/src/hooks/useNativeCopySelectedMessages.ts +++ b/src/hooks/useNativeCopySelectedMessages.ts @@ -11,7 +11,7 @@ const useNativeCopySelectedMessages = (copyMessagesByIds: ({ messageIds }: { mes } } - useHotkeys({ 'Meta+C': handleCopy }); + useHotkeys({ 'Mod+C': handleCopy }); }; export default useNativeCopySelectedMessages;