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

clientSettings.ts

33 lines1.4 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 { applyLanguage } from "../../i18n/messages.ts";
7import * as DesktopClientSettings from "../../settings/DesktopClientSettings.ts";
8import * as DesktopSnapShot from "../../snapShot/DesktopSnapShot.ts";
9import * as IpcChannels from "../channels.ts";
10import * as DesktopIpc from "../DesktopIpc.ts";
11​
12export const getClientSettings = DesktopIpc.makeIpcMethod({
13 channel: IpcChannels.GET_CLIENT_SETTINGS_CHANNEL,
14 payload: Schema.Void,
15 result: Schema.NullOr(ClientSettingsSchema),
16 handler: Effect.fn("desktop.ipc.clientSettings.get")(function* () {
17 const clientSettings = yield* DesktopClientSettings.DesktopClientSettings;
18 return Option.getOrNull(yield* clientSettings.get);
19 }),
20});
21​
22export const setClientSettings = DesktopIpc.makeIpcMethod({
23 channel: IpcChannels.SET_CLIENT_SETTINGS_CHANNEL,
24 payload: ClientSettingsSchema,
25 result: Schema.Void,
26 handler: Effect.fn("desktop.ipc.clientSettings.set")(function* (settings) {
27 const clientSettings = yield* DesktopClientSettings.DesktopClientSettings;
28 const snapShot = yield* DesktopSnapShot.DesktopSnapShot;
29 yield* clientSettings.set(settings);
30 yield* snapShot.configure(settings);
31 yield* applyLanguage(settings.language);
32 }),
33});