diff --git a/src/main/events/themes/toggle-custom-theme.ts b/src/main/events/themes/toggle-custom-theme.ts new file mode 100644 index 00000000..50440551 --- /dev/null +++ b/src/main/events/themes/toggle-custom-theme.ts @@ -0,0 +1,22 @@ +import { themesSublevel } from "@main/level"; +import { registerEvent } from "../register-event"; + +const toggleCustomTheme = async ( + _event: Electron.IpcMainInvokeEvent, + themeId: string, + isActive: boolean +) => { + const theme = await themesSublevel.get(themeId); + + if (!theme) { + throw new Error("Theme not found"); + } + + await themesSublevel.put(themeId, { + ...theme, + isActive, + updatedAt: new Date(), + }); +}; + +registerEvent("toggleCustomTheme", toggleCustomTheme);