| 1 | import * as Effect from "effect/Effect"; |
| 2 | import * as Option from "effect/Option"; |
| 3 | import * as Schema from "effect/Schema"; |
| 4 | |
| 5 | import * as DesktopConnectionCatalogStore from "../../app/DesktopConnectionCatalogStore.ts"; |
| 6 | import * as IpcChannels from "../channels.ts"; |
| 7 | import * as DesktopIpc from "../DesktopIpc.ts"; |
| 8 | |
| 9 | export const getConnectionCatalog = DesktopIpc.makeIpcMethod({ |
| 10 | channel: IpcChannels.GET_CONNECTION_CATALOG_CHANNEL, |
| 11 | payload: Schema.Void, |
| 12 | result: Schema.NullOr(Schema.String), |
| 13 | handler: Effect.fn("desktop.ipc.connectionCatalog.get")(function* () { |
| 14 | const store = yield* DesktopConnectionCatalogStore.DesktopConnectionCatalogStore; |
| 15 | return Option.getOrNull(yield* store.get); |
| 16 | }), |
| 17 | }); |
| 18 | |
| 19 | export const setConnectionCatalog = DesktopIpc.makeIpcMethod({ |
| 20 | channel: IpcChannels.SET_CONNECTION_CATALOG_CHANNEL, |
| 21 | payload: Schema.String, |
| 22 | result: Schema.Boolean, |
| 23 | handler: Effect.fn("desktop.ipc.connectionCatalog.set")(function* (catalog) { |
| 24 | const store = yield* DesktopConnectionCatalogStore.DesktopConnectionCatalogStore; |
| 25 | return yield* store.set(catalog); |
| 26 | }), |
| 27 | }); |
| 28 | |
| 29 | export const clearConnectionCatalog = DesktopIpc.makeIpcMethod({ |
| 30 | channel: IpcChannels.CLEAR_CONNECTION_CATALOG_CHANNEL, |
| 31 | payload: Schema.Void, |
| 32 | result: Schema.Void, |
| 33 | handler: Effect.fn("desktop.ipc.connectionCatalog.clear")(function* () { |
| 34 | const store = yield* DesktopConnectionCatalogStore.DesktopConnectionCatalogStore; |
| 35 | yield* store.clear; |
| 36 | }), |
| 37 | }); |