mirror of
https://github.com/owncast/owncast.git
synced 2025-11-12 02:17:57 +08:00
Add toggle chat keyboard shortcut. Closes #1892
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
|||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import { useRecoilState, useRecoilValue } from 'recoil';
|
import { useRecoilState, useRecoilValue } from 'recoil';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
import { useHotkeys } from 'react-hotkeys-hook';
|
||||||
import Modal from '../../ui/Modal/Modal';
|
import Modal from '../../ui/Modal/Modal';
|
||||||
import {
|
import {
|
||||||
chatVisibleToggleAtom,
|
chatVisibleToggleAtom,
|
||||||
@@ -29,17 +30,23 @@ export default function UserDropdown({ username: defaultUsername }: Props) {
|
|||||||
const appState = useRecoilValue<AppStateOptions>(appStateAtom);
|
const appState = useRecoilValue<AppStateOptions>(appStateAtom);
|
||||||
|
|
||||||
const toggleChatVisibility = () => {
|
const toggleChatVisibility = () => {
|
||||||
if (!chatToggleVisible) {
|
setChatToggleVisible(!chatToggleVisible);
|
||||||
setChatToggleVisible(true);
|
|
||||||
} else {
|
|
||||||
setChatToggleVisible(false);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleChangeName = () => {
|
const handleChangeName = () => {
|
||||||
setShowNameChangeModal(true);
|
setShowNameChangeModal(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Register keyboard shortcut for the space bar to toggle playback
|
||||||
|
useHotkeys(
|
||||||
|
'c',
|
||||||
|
toggleChatVisibility,
|
||||||
|
{
|
||||||
|
enableOnContentEditable: false,
|
||||||
|
},
|
||||||
|
[chatToggleVisible],
|
||||||
|
);
|
||||||
|
|
||||||
const menu = (
|
const menu = (
|
||||||
<Menu>
|
<Menu>
|
||||||
<Menu.Item key="0" icon={<EditOutlined />} onClick={() => handleChangeName()}>
|
<Menu.Item key="0" icon={<EditOutlined />} onClick={() => handleChangeName()}>
|
||||||
|
|||||||
Reference in New Issue
Block a user