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