Files
Netcatty/application/state/useApplicationBackend.ts
T
bincxz e238c4c20c Modularizes settings UI and removes modal settings dialog
Refactors the settings interface by deleting the monolithic modal dialog and splitting settings into dedicated tabs and components, improving maintainability and user experience. Enables application info retrieval through a new IPC bridge for use in About/Application screens. Streamlines code by removing redundant state and logic tied to the old settings modal.
2025-12-17 01:48:46 +08:00

33 lines
849 B
TypeScript

import { useCallback } from "react";
import { netcattyBridge } from "../../infrastructure/services/netcattyBridge";
export type ApplicationInfo = {
name: string;
version: string;
platform: string;
};
export const useApplicationBackend = () => {
const openExternal = useCallback(async (url: string) => {
try {
const bridge = netcattyBridge.get();
if (bridge?.openExternal) {
await bridge.openExternal(url);
return;
}
} catch {
// Ignore and fall back below
}
window.open(url, "_blank", "noopener,noreferrer");
}, []);
const getApplicationInfo = useCallback(async (): Promise<ApplicationInfo | null> => {
const bridge = netcattyBridge.get();
const info = await bridge?.getAppInfo?.();
return info ?? null;
}, []);
return { openExternal, getApplicationInfo };
};