mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-11-15 21:22:18 +01:00
Settings opens in a window labelled `settings`, created through the shared window code, as Yaak's does. The page renders the settings alone or the app by its window label. Opening it again focuses it and moves it to the tab asked for; Escape closes it, and closing the main window closes it too. Changes made there reach the main window at once: theme and sizes by an event carrying the values, and engine settings by an event after each RPC mutation that makes other windows read the proxy state and settings queries again. The browser harness, with no second window, keeps the dialog. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
21 lines
802 B
TypeScript
21 lines
802 B
TypeScript
import { type UseMutationOptions, useMutation } from "@tanstack/react-query";
|
|
import type { RpcSchema } from "@yaakapp-internal/proxy-lib";
|
|
import { minPromiseMillis } from "@yaakapp-internal/ui";
|
|
import type { Req, Res } from "../lib/rpc";
|
|
import { rpc } from "../lib/rpc";
|
|
import { announceEngineChange } from "../lib/windowSync";
|
|
|
|
/**
|
|
* React Query mutation wrapper for RPC commands. The app's other windows hear of each one once
|
|
* it settles, and read again what it may have changed.
|
|
*/
|
|
export function useRpcMutation<K extends keyof RpcSchema>(
|
|
cmd: K,
|
|
opts?: Omit<UseMutationOptions<Res<K>, Error, Req<K>>, "mutationFn">,
|
|
) {
|
|
return useMutation<Res<K>, Error, Req<K>>({
|
|
mutationFn: (payload) => minPromiseMillis(rpc(cmd, payload)).finally(announceEngineChange),
|
|
...opts,
|
|
});
|
|
}
|