Open History to see the last commit
1import {
2 DesktopUpdateActionResultSchema,
3 DesktopUpdateChannelSchema,
4 DesktopUpdateCheckResultSchema,
5 DesktopUpdateStateSchema,
6} from "@t3tools/contracts";
7import * as Effect from "effect/Effect";
8import * as Schema from "effect/Schema";
9
10import * as DesktopUpdates from "../../updates/DesktopUpdates.ts";
11import * as IpcChannels from "../channels.ts";
12import * as DesktopIpc from "../DesktopIpc.ts";
13
14export const getUpdateState = DesktopIpc.makeIpcMethod({
15 channel: IpcChannels.UPDATE_GET_STATE_CHANNEL,
16 payload: Schema.Void,
17 result: DesktopUpdateStateSchema,
18 handler: Effect.fn("desktop.ipc.updates.getState")(function* () {
19 const updates = yield* DesktopUpdates.DesktopUpdates;
20 yield* updates.whenConfigured;
21 return yield* updates.getState;
22 }),
23});
24
25export const setUpdateChannel = DesktopIpc.makeIpcMethod({
26 channel: IpcChannels.UPDATE_SET_CHANNEL_CHANNEL,
27 payload: DesktopUpdateChannelSchema,
28 result: DesktopUpdateStateSchema,
29 handler: Effect.fn("desktop.ipc.updates.setChannel")(function* (channel) {
30 const updates = yield* DesktopUpdates.DesktopUpdates;
31 yield* updates.whenConfigured;
32 return yield* updates.setChannel(channel);
33 }),
34});
35
36export const downloadUpdate = DesktopIpc.makeIpcMethod({
37 channel: IpcChannels.UPDATE_DOWNLOAD_CHANNEL,
38 payload: Schema.Void,
39 result: DesktopUpdateActionResultSchema,
40 handler: Effect.fn("desktop.ipc.updates.download")(function* () {
41 const updates = yield* DesktopUpdates.DesktopUpdates;
42 yield* updates.whenConfigured;
43 return yield* updates.download;
44 }),
45});
46
47export const installUpdate = DesktopIpc.makeIpcMethod({
48 channel: IpcChannels.UPDATE_INSTALL_CHANNEL,
49 payload: Schema.Void,
50 result: DesktopUpdateActionResultSchema,
51 handler: Effect.fn("desktop.ipc.updates.install")(function* () {
52 const updates = yield* DesktopUpdates.DesktopUpdates;
53 yield* updates.whenConfigured;
54 return yield* updates.install;
55 }),
56});
57
58export const checkForUpdate = DesktopIpc.makeIpcMethod({
59 channel: IpcChannels.UPDATE_CHECK_CHANNEL,
60 payload: Schema.Void,
61 result: DesktopUpdateCheckResultSchema,
62 handler: Effect.fn("desktop.ipc.updates.check")(function* () {
63 const updates = yield* DesktopUpdates.DesktopUpdates;
64 yield* updates.whenConfigured;
65 return yield* updates.check("web-ui");
66 }),
67});