Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

desktop: zod considers false as undefined and throws error

Abdullah Atta8df9c49fa1d0
diff --git a/apps/desktop/src/api/os-integration.ts b/apps/desktop/src/api/os-integration.ts
index 73d5b5e03..0b9b35ff5 100644
--- a/apps/desktop/src/api/os-integration.ts
+++ b/apps/desktop/src/api/os-integration.ts
@@ -52,12 +52,12 @@ export const osIntegrationRouter = t.router({
privacyMode: t.procedure.query(() => config.privacyMode),
setPrivacyMode: t.procedure
- .input(z.boolean())
+ .input(z.boolean().optional())
.mutation(({ input: privacyMode }) => {
if (!globalThis.window || !["win32", "darwin"].includes(process.platform))
return;
- globalThis.window.setContentProtection(privacyMode);
+ globalThis.window.setContentProtection(!!privacyMode);
if (process.platform === "win32") {
globalThis.window.setThumbnailClip(
@@ -66,7 +66,7 @@ export const osIntegrationRouter = t.router({
: { x: 0, y: 0, width: 0, height: 0 }
);
}
- config.privacyMode = privacyMode;
+ config.privacyMode = !!privacyMode;
}),
desktopIntegration: t.procedure.query(() => config.desktopSettings),
@@ -74,7 +74,7 @@ export const osIntegrationRouter = t.router({
.input(DesktopIntegration)
.mutation(({ input: settings }) => {
if (settings.autoStart) {
- AutoLaunch.enable(settings.startMinimized);
+ AutoLaunch.enable(!!settings.startMinimized);
} else {
AutoLaunch.disable();
}
diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.ts
index 9c1c28473..048718d48 100644
--- a/apps/desktop/src/main.ts
+++ b/apps/desktop/src/main.ts
@@ -216,6 +216,6 @@ function setupDesktopIntegration(hidden: boolean) {
});
if (desktopIntegration.autoStart) {
- AutoLaunch.enable(desktopIntegration.startMinimized);
+ AutoLaunch.enable(!!desktopIntegration.startMinimized);
}
}
diff --git a/apps/desktop/src/utils/config.ts b/apps/desktop/src/utils/config.ts
index d9f8c04d4..83bbf1bb9 100644
--- a/apps/desktop/src/utils/config.ts
+++ b/apps/desktop/src/utils/config.ts
@@ -22,10 +22,10 @@ import { JSONStorage } from "./json-storage";
import { z } from "zod";
export const DesktopIntegration = z.object({
- autoStart: z.boolean(),
- startMinimized: z.boolean(),
- minimizeToSystemTray: z.boolean(),
- closeToSystemTray: z.boolean()
+ autoStart: z.boolean().optional(),
+ startMinimized: z.boolean().optional(),
+ minimizeToSystemTray: z.boolean().optional(),
+ closeToSystemTray: z.boolean().optional()
});
export type DesktopIntegration = z.infer<typeof DesktopIntegration>;