c for opening composer, shift+c for opening it in new window

This commit is contained in:
Lim Chee Aun 2023-09-05 21:44:38 +08:00
parent 2540135962
commit e4174b49d5

View file

@ -1,26 +1,33 @@
import { useHotkeys } from 'react-hotkeys-hook';
import openCompose from '../utils/open-compose'; import openCompose from '../utils/open-compose';
import states from '../utils/states'; import states from '../utils/states';
import Icon from './icon'; import Icon from './icon';
export default function ComposeButton() { export default function ComposeButton() {
return ( function handleButton(e) {
<button if (e.shiftKey) {
type="button" const newWin = openCompose();
id="compose-button"
onClick={(e) => {
if (e.shiftKey) {
const newWin = openCompose();
if (!newWin) { if (!newWin) {
alert('Looks like your browser is blocking popups.'); alert('Looks like your browser is blocking popups.');
states.showCompose = true; states.showCompose = true;
} }
} else { } else {
states.showCompose = true; states.showCompose = true;
} }
}} }
>
useHotkeys('c, shift+c', handleButton, {
ignoreEventWhen: (e) => {
const hasModal = !!document.querySelector('#modal-container > *');
return hasModal;
},
});
return (
<button type="button" id="compose-button" onClick={handleButton}>
<Icon icon="quill" size="xl" alt="Compose" /> <Icon icon="quill" size="xl" alt="Compose" />
</button> </button>
); );