mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-10-09 15:58:34 +00:00
e238c4c20c
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.
33 lines
849 B
TypeScript
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 };
|
|
};
|
|
|