From b14a8450a7d50c726dc66ba896bb2e87b172e8af Mon Sep 17 00:00:00 2001 From: "serafim.eth" <147140426+ulugmer@users.noreply.github.com> Date: Wed, 15 Nov 2023 15:04:41 +0800 Subject: [PATCH 1/2] go to inbox --- src/components/left/main/UluSystemChatFolders.tsx | 4 ++++ src/components/main/CommandMenu.tsx | 8 ++++++++ src/hooks/useCommands.ts | 1 + 3 files changed, 13 insertions(+) diff --git a/src/components/left/main/UluSystemChatFolders.tsx b/src/components/left/main/UluSystemChatFolders.tsx index 9e2e6a640b..064fcaa680 100644 --- a/src/components/left/main/UluSystemChatFolders.tsx +++ b/src/components/left/main/UluSystemChatFolders.tsx @@ -9,6 +9,7 @@ import { ALL_FOLDER_ID, ARCHIVED_FOLDER_ID } from '../../../config'; import { selectIsChatWithSelf, selectTabState } from '../../../global/selectors'; import { uluGetTranslatedString } from '../../../util/fallbackLangPackInitial'; +import useCommands from '../../../hooks/useCommands'; import { useFolderManagerForUnreadCounters } from '../../../hooks/useFolderManager'; import UluChatFolder from './UluChatFolder'; @@ -48,6 +49,9 @@ const UluSystemFolders: FC = ({ setActiveChatFolder({ activeChatFolder: ALL_FOLDER_ID }); }, [setActiveChatFolder]); + const { useCommand } = useCommands(); + useCommand('OPEN_INBOX', handleOpenInbox); + const unreadCounters = useFolderManagerForUnreadCounters(); const archiveUnreadCount = unreadCounters[ARCHIVED_FOLDER_ID]?.activeChatsCount; const savedMessagesUnreadCount = userId ? unreadCounters[userId]?.chatsCount : 0; diff --git a/src/components/main/CommandMenu.tsx b/src/components/main/CommandMenu.tsx index c8f8c83859..39c8520013 100644 --- a/src/components/main/CommandMenu.tsx +++ b/src/components/main/CommandMenu.tsx @@ -170,6 +170,11 @@ const CommandMenu: FC = ({ topUserIds, usersById }) => { close(); }, [runCommand, close]); + const handleOpenInbox = useCallback(() => { + runCommand('OPEN_INBOX'); + close(); + }, [runCommand, close]); + /* const commandToggleArchiver = useCallback(() => { const updIsArchiverEnabled = !isArchiverEnabled; showNotification({ message: updIsArchiverEnabled ? 'Archiver enabled!' : 'Archiver disabled!' }); @@ -231,6 +236,9 @@ const CommandMenu: FC = ({ topUserIds, usersById }) => { Go to archive + + Go to inbox + Go to settings diff --git a/src/hooks/useCommands.ts b/src/hooks/useCommands.ts index f5138ef0e4..a9e64b0285 100644 --- a/src/hooks/useCommands.ts +++ b/src/hooks/useCommands.ts @@ -7,6 +7,7 @@ type TCommand = ( | 'OPEN_SEARCH' | 'OPEN_SETTINGS' | 'OPEN_ARCHIVED' + | 'OPEN_INBOX' ); export default function useCommands() { From 8c7b94aecaac10013d2fbe8d7ffe38830e38f363 Mon Sep 17 00:00:00 2001 From: "serafim.eth" <147140426+ulugmer@users.noreply.github.com> Date: Wed, 15 Nov 2023 15:11:33 +0800 Subject: [PATCH 2/2] go to saved messages --- .../left/main/UluSystemChatFolders.tsx | 1 + src/components/main/CommandMenu.tsx | 24 +++++++++++++------ src/hooks/useCommands.ts | 1 + 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/components/left/main/UluSystemChatFolders.tsx b/src/components/left/main/UluSystemChatFolders.tsx index 064fcaa680..25ec55c81a 100644 --- a/src/components/left/main/UluSystemChatFolders.tsx +++ b/src/components/left/main/UluSystemChatFolders.tsx @@ -51,6 +51,7 @@ const UluSystemFolders: FC = ({ const { useCommand } = useCommands(); useCommand('OPEN_INBOX', handleOpenInbox); + useCommand('OPEN_SAVED', handleOpenSavedMessages); const unreadCounters = useFolderManagerForUnreadCounters(); const archiveUnreadCount = unreadCounters[ARCHIVED_FOLDER_ID]?.activeChatsCount; diff --git a/src/components/main/CommandMenu.tsx b/src/components/main/CommandMenu.tsx index 39c8520013..65486e1ac9 100644 --- a/src/components/main/CommandMenu.tsx +++ b/src/components/main/CommandMenu.tsx @@ -175,6 +175,11 @@ const CommandMenu: FC = ({ topUserIds, usersById }) => { close(); }, [runCommand, close]); + const handleOpenSavedMessages = useCallback(() => { + runCommand('OPEN_SAVED'); + close(); + }, [runCommand, close]); + /* const commandToggleArchiver = useCallback(() => { const updIsArchiverEnabled = !isArchiverEnabled; showNotification({ message: updIsArchiverEnabled ? 'Archiver enabled!' : 'Archiver disabled!' }); @@ -198,14 +203,15 @@ const CommandMenu: FC = ({ topUserIds, usersById }) => { topUserIds: string[]; usersById: Record; handleSearchFocus: () => void; + handleOpenSavedMessages: () => void; + handleSelectSettings: () => void; + handleSelectArchived: () => void; } interface CreateNewPageProps { handleSelectNewGroup: () => void; handleSelectNewChannel: () => void; handleCreateFolder: () => void; - handleSelectSettings: () => void; - handleSelectArchived: () => void; } const HomePage: React.FC = ({ @@ -233,12 +239,15 @@ const CommandMenu: FC = ({ topUserIds, usersById }) => { / - - Go to archive - Go to inbox + + Go to saved messages + + + Go to archive + Go to settings @@ -296,6 +305,9 @@ const CommandMenu: FC = ({ topUserIds, usersById }) => { topUserIds={topUserIds} usersById={usersById} handleSearchFocus={handleSearchFocus} + handleSelectSettings={handleSelectSettings} + handleSelectArchived={handleSelectArchived} + handleOpenSavedMessages={handleOpenSavedMessages} /> )} {activePage === 'createNew' && ( @@ -303,8 +315,6 @@ const CommandMenu: FC = ({ topUserIds, usersById }) => { handleSelectNewGroup={handleSelectNewGroup} handleSelectNewChannel={handleSelectNewChannel} handleCreateFolder={handleCreateFolder} - handleSelectSettings={handleSelectSettings} - handleSelectArchived={handleSelectArchived} /> )} diff --git a/src/hooks/useCommands.ts b/src/hooks/useCommands.ts index a9e64b0285..36a10b9f70 100644 --- a/src/hooks/useCommands.ts +++ b/src/hooks/useCommands.ts @@ -8,6 +8,7 @@ type TCommand = ( | 'OPEN_SETTINGS' | 'OPEN_ARCHIVED' | 'OPEN_INBOX' + | 'OPEN_SAVED' ); export default function useCommands() {