Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

clientSettings.ts

28 lines1.1 KB

1import { ClientSettingsSchema } from "@t3tools/contracts";
2import * as Effect from "effect/Effect";
3import * as Option from "effect/Option";
4import * as Schema from "effect/Schema";
5​
6import * as DesktopClientSettings from "../../settings/DesktopClientSettings.ts";
7import * as IpcChannels from "../channels.ts";
8import * as DesktopIpc from "../DesktopIpc.ts";
9​
10export const getClientSettings = DesktopIpc.makeIpcMethod({
11 channel: IpcChannels.GET_CLIENT_SETTINGS_CHANNEL,
12 payload: Schema.Void,
13 result: Schema.NullOr(ClientSettingsSchema),
14 handler: Effect.fn("desktop.ipc.clientSettings.get")(function* () {
15 const clientSettings = yield* DesktopClientSettings.DesktopClientSettings;
16 return Option.getOrNull(yield* clientSettings.get);
17 }),
18});
19​
20export const setClientSettings = DesktopIpc.makeIpcMethod({
21 channel: IpcChannels.SET_CLIENT_SETTINGS_CHANNEL,
22 payload: ClientSettingsSchema,
23 result: Schema.Void,
24 handler: Effect.fn("desktop.ipc.clientSettings.set")(function* (settings) {
25 const clientSettings = yield* DesktopClientSettings.DesktopClientSettings;
26 yield* clientSettings.set(settings);
27 }),
28});