Skip to content

Commit

Permalink
Merge pull request #94 from ulu-telegram/master
Browse files Browse the repository at this point in the history
deploy
  • Loading branch information
ulugmer authored Nov 17, 2023
2 parents ce49ad4 + aecb567 commit 7f4c847
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/components/left/main/LeftMainHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ const LeftMainHeader: FC<OwnProps & StateProps> = ({
});

useHotkeys(canSetPasscode ? {
'Ctrl+Shift+L': handleLockScreenHotkey,
'Alt+Shift+L': handleLockScreenHotkey,
'Meta+Shift+L': handleLockScreenHotkey,
...(IS_APP && { 'Mod+L': handleLockScreenHotkey }),
} : undefined);
Expand All @@ -161,6 +159,7 @@ const LeftMainHeader: FC<OwnProps & StateProps> = ({
});

useCommand('OPEN_SEARCH', handleSearchFocus);
useCommand('LOCK_SCREEN', handleLockScreenHotkey);

// Cmd+/ to open search
useEffect(() => {
Expand Down Expand Up @@ -324,9 +323,9 @@ const LeftMainHeader: FC<OwnProps & StateProps> = ({
<Button
round
ripple={!isMobile}
size="smaller"
size="tiny"
color="translucent"
ariaLabel={`${lang('ShortcutsController.Others.LockByPasscode')} (Ctrl+Shift+L)`}
ariaLabel={`${lang('ShortcutsController.Others.LockByPasscode')} '⌘+L')`}
onClick={handleLockScreen}
className={buildClassName(!isCurrentUserPremium && 'extra-spacing')}
>
Expand Down
34 changes: 31 additions & 3 deletions src/components/main/CommandMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { getActions, withGlobal } from '../../global';

import type { ApiUser } from '../../api/types';

import { FAQ_URL } from '../../config';
import { FAQ_URL, SHORTCUTS_URL } from '../../config';
import { getMainUsername, getUserFullName } from '../../global/helpers';
import captureKeyboardListeners from '../../util/captureKeyboardListeners';
import { convertLayout } from '../../util/convertLayout';
Expand Down Expand Up @@ -119,10 +119,12 @@ interface HomePageProps {
close: () => void;
handleSupport: () => void;
handleFAQ: () => void;
handleOpenShortcuts: () => void;
handleChangelog: () => void;
handleSelectNewGroup: () => void;
handleSelectNewChannel: () => void;
handleCreateFolder: () => void;
handleLockScreenHotkey: () => void;
}

interface CreateNewPageProps {
Expand All @@ -136,6 +138,7 @@ const HomePage: React.FC<HomePageProps> = ({
handleSearchFocus, handleOpenSavedMessages, handleSelectSettings,
handleSelectArchived, handleOpenInbox, menuItems, saveAPIKey,
handleSupport, handleFAQ, handleChangelog, handleSelectNewGroup, handleCreateFolder, handleSelectNewChannel,
handleOpenShortcuts, handleLockScreenHotkey,
}) => {
return (
<>
Expand Down Expand Up @@ -180,7 +183,7 @@ const HomePage: React.FC<HomePageProps> = ({
<Command.Item onSelect={handleFAQ}>
<i className="icon icon-document" /><span>Open FAQ</span>
</Command.Item>
<Command.Item onSelect={handleFAQ}>
<Command.Item onSelect={handleOpenShortcuts}>
<i className="icon icon-keyboard" /><span>Keyboard shortcuts</span>
</Command.Item>
<Command.Item onSelect={handleSupport}>
Expand All @@ -203,6 +206,13 @@ const HomePage: React.FC<HomePageProps> = ({
<span className="kbd">/</span>
</span>
</Command.Item>
{
IS_ARC_BROWSER && (
<Command.Item onSelect={handleLockScreenHotkey}>
<i className="icon icon-lock" /><span>Lock screen</span>
</Command.Item>
)
}
<Command.Item onSelect={handleOpenInbox}>
<i className="icon icon-unread" /><span>Go to inbox</span>
</Command.Item>
Expand Down Expand Up @@ -333,7 +343,18 @@ const CommandMenu: FC<CommandMenuProps> = ({ topUserIds, usersById }) => {
}, [openChatByUsername, close]);

const handleFAQ = useCallback(() => {
openUrl({ url: FAQ_URL });
openUrl({
url: FAQ_URL,
shouldSkipModal: true,
});
close();
}, [openUrl, close]);

const handleOpenShortcts = useCallback(() => {
openUrl({
url: SHORTCUTS_URL,
shouldSkipModal: true,
});
close();
}, [openUrl, close]);

Expand Down Expand Up @@ -382,6 +403,11 @@ const CommandMenu: FC<CommandMenuProps> = ({ topUserIds, usersById }) => {
close();
}, [runCommand, close]);

const handleLockScreenHotkey = useCallback(() => {
runCommand('LOCK_SCREEN');
close();
}, [runCommand, close]);

/* const commandToggleArchiver = useCallback(() => {
const updIsArchiverEnabled = !isArchiverEnabled;
showNotification({ message: updIsArchiverEnabled ? 'Archiver enabled!' : 'Archiver disabled!' });
Expand Down Expand Up @@ -453,11 +479,13 @@ const CommandMenu: FC<CommandMenuProps> = ({ topUserIds, usersById }) => {
menuItems={menuItems}
handleSupport={handleSupport}
handleFAQ={handleFAQ}
handleOpenShortcuts={handleOpenShortcts}
handleChangelog={handleChangelog}
close={close}
handleSelectNewGroup={handleSelectNewGroup}
handleSelectNewChannel={handleSelectNewChannel}
handleCreateFolder={handleCreateFolder}
handleLockScreenHotkey={handleLockScreenHotkey}
/>
)}
{activePage === 'createNew' && (
Expand Down
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ export const DEFAULT_LANG_PACK = 'android';
export const LANG_PACKS = ['android', 'ios', 'tdesktop', 'macos'] as const;
export const FEEDBACK_URL = 'https://bugs.telegram.org/?tag_ids=41&sort=time';
export const FAQ_URL = 'https://ulumessenger.notion.site/Getting-Started-with-ulu-046fcebdeb7b41a1b10c0a0b6b07ca75';
// eslint-disable-next-line max-len
export const SHORTCUTS_URL = 'https://ulumessenger.notion.site/Getting-Started-with-ulu-046fcebdeb7b41a1b10c0a0b6b07ca75?pvs=4#3049aec77dc14baaa3c3a186f5bafb52';
export const PRIVACY_URL = 'https://telegram.org/privacy';
export const MINI_APP_TOS_URL = 'https://telegram.org/tos/mini-apps';
export const GENERAL_TOPIC_ID = 1;
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type TCommand = (
| 'OPEN_ARCHIVED'
| 'OPEN_INBOX'
| 'OPEN_SAVED'
| 'LOCK_SCREEN'
);

export default function useCommands() {
Expand Down

0 comments on commit 7f4c847

Please sign in to comment.