Skip to content

Commit

Permalink
Merge pull request #78 from ulu-telegram/master
Browse files Browse the repository at this point in the history
Do to Saved and Inbox
  • Loading branch information
ulugmer authored Nov 15, 2023
2 parents ce05360 + 8c7b94a commit 11655b1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/components/left/main/UluSystemChatFolders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -48,6 +49,10 @@ const UluSystemFolders: FC<OwnProps & StateProps> = ({
setActiveChatFolder({ activeChatFolder: ALL_FOLDER_ID });
}, [setActiveChatFolder]);

const { useCommand } = useCommands();
useCommand('OPEN_INBOX', handleOpenInbox);
useCommand('OPEN_SAVED', handleOpenSavedMessages);

const unreadCounters = useFolderManagerForUnreadCounters();
const archiveUnreadCount = unreadCounters[ARCHIVED_FOLDER_ID]?.activeChatsCount;
const savedMessagesUnreadCount = userId ? unreadCounters[userId]?.chatsCount : 0;
Expand Down
26 changes: 22 additions & 4 deletions src/components/main/CommandMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ const CommandMenu: FC<CommandMenuProps> = ({ topUserIds, usersById }) => {
close();
}, [runCommand, close]);

const handleOpenInbox = useCallback(() => {
runCommand('OPEN_INBOX');
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!' });
Expand All @@ -193,14 +203,15 @@ const CommandMenu: FC<CommandMenuProps> = ({ topUserIds, usersById }) => {
topUserIds: string[];
usersById: Record<string, ApiUser>;
handleSearchFocus: () => void;
handleOpenSavedMessages: () => void;
handleSelectSettings: () => void;
handleSelectArchived: () => void;
}

interface CreateNewPageProps {
handleSelectNewGroup: () => void;
handleSelectNewChannel: () => void;
handleCreateFolder: () => void;
handleSelectSettings: () => void;
handleSelectArchived: () => void;
}

const HomePage: React.FC<HomePageProps> = ({
Expand Down Expand Up @@ -228,6 +239,12 @@ const CommandMenu: FC<CommandMenuProps> = ({ topUserIds, usersById }) => {
<span className="kbd">/</span>
</span>
</Command.Item>
<Command.Item onSelect={handleOpenInbox}>
<i className="icon icon-unread" /><span>Go to inbox</span>
</Command.Item>
<Command.Item onSelect={handleOpenSavedMessages}>
<i className="icon icon-saved-messages" /><span>Go to saved messages</span>
</Command.Item>
<Command.Item onSelect={handleSelectArchived}>
<i className="icon icon-archive-from-main" /><span>Go to archive</span>
</Command.Item>
Expand Down Expand Up @@ -288,15 +305,16 @@ const CommandMenu: FC<CommandMenuProps> = ({ topUserIds, usersById }) => {
topUserIds={topUserIds}
usersById={usersById}
handleSearchFocus={handleSearchFocus}
handleSelectSettings={handleSelectSettings}
handleSelectArchived={handleSelectArchived}
handleOpenSavedMessages={handleOpenSavedMessages}
/>
)}
{activePage === 'createNew' && (
<CreateNewPage
handleSelectNewGroup={handleSelectNewGroup}
handleSelectNewChannel={handleSelectNewChannel}
handleCreateFolder={handleCreateFolder}
handleSelectSettings={handleSelectSettings}
handleSelectArchived={handleSelectArchived}
/>
)}
</Command.List>
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/useCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ type TCommand = (
| 'OPEN_SEARCH'
| 'OPEN_SETTINGS'
| 'OPEN_ARCHIVED'
| 'OPEN_INBOX'
| 'OPEN_SAVED'
);

export default function useCommands() {
Expand Down

0 comments on commit 11655b1

Please sign in to comment.