Browse Source

Add toggle chat keyboard shortcut. Closes #1892

pull/2032/head
Gabe Kangas 4 years ago
parent
commit
e6b857f3b2
No known key found for this signature in database
GPG Key ID: 9A56337728BC81EA
  1. 17
      web/components/common/UserDropdown/UserDropdown.tsx

17
web/components/common/UserDropdown/UserDropdown.tsx

@ -8,6 +8,7 @@ import { @@ -8,6 +8,7 @@ import {
} from '@ant-design/icons';
import { useRecoilState, useRecoilValue } from 'recoil';
import { useState } from 'react';
import { useHotkeys } from 'react-hotkeys-hook';
import Modal from '../../ui/Modal/Modal';
import {
chatVisibleToggleAtom,
@ -29,17 +30,23 @@ export default function UserDropdown({ username: defaultUsername }: Props) { @@ -29,17 +30,23 @@ export default function UserDropdown({ username: defaultUsername }: Props) {
const appState = useRecoilValue<AppStateOptions>(appStateAtom);
const toggleChatVisibility = () => {
if (!chatToggleVisible) {
setChatToggleVisible(true);
} else {
setChatToggleVisible(false);
}
setChatToggleVisible(!chatToggleVisible);
};
const handleChangeName = () => {
setShowNameChangeModal(true);
};
// Register keyboard shortcut for the space bar to toggle playback
useHotkeys(
'c',
toggleChatVisibility,
{
enableOnContentEditable: false,
},
[chatToggleVisible],
);
const menu = (
<Menu>
<Menu.Item key="0" icon={<EditOutlined />} onClick={() => handleChangeName()}>

Loading…
Cancel
Save