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

connectionCatalog.ts

27 lines1.1 KB

1import * as Effect from "effect/Effect";
2import * as Option from "effect/Option";
3import * as Schema from "effect/Schema";
4​
5import * as DesktopConnectionCatalogStore from "../../app/DesktopConnectionCatalogStore.ts";
6import * as IpcChannels from "../channels.ts";
7import * as DesktopIpc from "../DesktopIpc.ts";
8​
9export 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​
19export 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});