Fix bundle parts

This commit is contained in:
Gregory Schier
2023-03-29 14:00:34 -07:00
parent ab15782019
commit 06ce7abfb9
5 changed files with 65 additions and 32 deletions

View File

@@ -0,0 +1,20 @@
import { appWindow } from '@tauri-apps/api/window';
import { useEffect, useState } from 'react';
export function useWindowFocus() {
const [visible, setVisible] = useState(true);
useEffect(() => {
let unsub: undefined | (() => void) = undefined;
appWindow
.onFocusChanged((e) => {
setVisible(e.payload);
})
.then((fn) => {
unsub = fn;
});
return () => unsub?.();
}, []);
return visible;
}