mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-10-09 15:58:34 +00:00
0ac351b41a
Defers Electron window display until the renderer signals first meaningful paint, avoiding initial blank screens or white flashes, especially on startup and settings windows. Implements a handshake using a renderer-to-main process message, color-matches background to the current theme, and falls back to a timeout in development. Also migrates font loading to npm packages, replaces Google Fonts usage, and adds code-splitting for dialogs and quick switcher to improve performance. Restricts console debug output to development.
54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import { useCallback } from "react";
|
|
import { netcattyBridge } from "../../infrastructure/services/netcattyBridge";
|
|
|
|
export const useWindowControls = () => {
|
|
const notifyRendererReady = useCallback(() => {
|
|
try {
|
|
netcattyBridge.get()?.rendererReady?.();
|
|
} catch {
|
|
// ignore
|
|
}
|
|
}, []);
|
|
|
|
const closeSettingsWindow = useCallback(async () => {
|
|
const bridge = netcattyBridge.get();
|
|
await bridge?.closeSettingsWindow?.();
|
|
}, []);
|
|
|
|
const openSettingsWindow = useCallback(async () => {
|
|
const bridge = netcattyBridge.get();
|
|
return bridge?.openSettingsWindow?.();
|
|
}, []);
|
|
|
|
const minimize = useCallback(async () => {
|
|
const bridge = netcattyBridge.get();
|
|
await bridge?.windowMinimize?.();
|
|
}, []);
|
|
|
|
const maximize = useCallback(async () => {
|
|
const bridge = netcattyBridge.get();
|
|
return bridge?.windowMaximize?.();
|
|
}, []);
|
|
|
|
const close = useCallback(async () => {
|
|
const bridge = netcattyBridge.get();
|
|
await bridge?.windowClose?.();
|
|
}, []);
|
|
|
|
const isMaximized = useCallback(async () => {
|
|
const bridge = netcattyBridge.get();
|
|
return bridge?.windowIsMaximized?.();
|
|
}, []);
|
|
|
|
return {
|
|
notifyRendererReady,
|
|
closeSettingsWindow,
|
|
openSettingsWindow,
|
|
minimize,
|
|
maximize,
|
|
close,
|
|
isMaximized,
|
|
};
|
|
};
|
|
|