add composer shortcut
This commit is contained in:
@@ -9,7 +9,7 @@ export function Button({
|
||||
}: {
|
||||
preset: "small" | "publish" | "large";
|
||||
children: ReactNode;
|
||||
disabled: boolean;
|
||||
disabled?: boolean;
|
||||
onClick?: () => void;
|
||||
}) {
|
||||
let preClass: string;
|
||||
|
||||
@@ -10,7 +10,9 @@ import {
|
||||
} from "@shared/icons";
|
||||
import { useActiveAccount } from "@stores/accounts";
|
||||
import { useComposer } from "@stores/composer";
|
||||
import { Fragment } from "react";
|
||||
import { COMPOSE_SHORTCUT } from "@stores/shortcuts";
|
||||
import { register } from "@tauri-apps/api/globalShortcut";
|
||||
import { Fragment, useEffect } from "react";
|
||||
|
||||
export function Composer() {
|
||||
const account = useActiveAccount((state: any) => state.account);
|
||||
@@ -23,6 +25,16 @@ export function Composer() {
|
||||
toggle(false);
|
||||
};
|
||||
|
||||
const registerShortcut = async () => {
|
||||
await register(COMPOSE_SHORTCUT, () => {
|
||||
toggle(true);
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
registerShortcut();
|
||||
}, [registerShortcut]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button onClick={() => toggle(true)} preset="small">
|
||||
|
||||
1
src/stores/shortcuts.tsx
Normal file
1
src/stores/shortcuts.tsx
Normal file
@@ -0,0 +1 @@
|
||||
export const COMPOSE_SHORTCUT = "CommandOrControl+N";
|
||||
Reference in New Issue
Block a user