hotkey to activate neko interactions

This commit is contained in:
2026-01-05 16:40:27 +08:00
parent 96ba44613d
commit ca995899fe
5 changed files with 196 additions and 31 deletions

View File

@@ -0,0 +1,37 @@
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
import { writable } from "svelte/store";
export const sceneInteractive = writable<boolean>(false);
let unlisten: UnlistenFn | null = null;
let isListening = false;
export async function initSceneInteractiveListener() {
if (isListening) return;
try {
// ensure initial default matches backend default
sceneInteractive.set(false);
unlisten = await listen<boolean>("scene-interactive", (event) => {
sceneInteractive.set(Boolean(event.payload));
});
isListening = true;
} catch (error) {
console.error("Failed to initialize scene interactive listener:", error);
throw error;
}
}
export function stopSceneInteractiveListener() {
if (unlisten) {
unlisten();
unlisten = null;
isListening = false;
}
}
if (import.meta.hot) {
import.meta.hot.dispose(() => {
stopSceneInteractiveListener();
});
}