[bugfix] to register hotkeys when start up the software.(to unregisterAll when the software is updating)

This commit is contained in:
Sakamoto Shiina
2025-01-20 12:06:05 +09:00
parent d074b3e881
commit 16b41c8102
3 changed files with 25 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
import { useEffect } from "react";
import { useHotkeys } from "@logics_configs";
import { useIsBackendReady, useIsSoftwareUpdating } from "@logics_common";
export const GlobalHotKeyController = () => {
const { currentIsBackendReady } = useIsBackendReady();
const { currentIsSoftwareUpdating } = useIsSoftwareUpdating();
const { registerShortcuts, unregisterAll } = useHotkeys();
useEffect(() => {
const is_backend_ready = currentIsBackendReady.data;
const is_software_updating = currentIsSoftwareUpdating.data;
if (is_backend_ready && !is_software_updating) {
registerShortcuts();
} else if (is_software_updating) {
unregisterAll();
}
}, [currentIsBackendReady.data, currentIsSoftwareUpdating.data]);
return null;
};