mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-28 05:11:02 +00:00
29 lines
704 B
TypeScript
29 lines
704 B
TypeScript
import { themesSublevel } from "@main/level";
|
|
import { registerEvent } from "../register-event";
|
|
import { WindowManager } from "@main/services";
|
|
|
|
const updateCustomTheme = async (
|
|
_event: Electron.IpcMainInvokeEvent,
|
|
themeId: string,
|
|
code: string
|
|
) => {
|
|
const theme = await themesSublevel.get(themeId);
|
|
|
|
if (!theme) {
|
|
throw new Error("Theme not found");
|
|
}
|
|
|
|
await themesSublevel.put(themeId, {
|
|
...theme,
|
|
code,
|
|
updatedAt: new Date(),
|
|
});
|
|
|
|
if (theme.isActive) {
|
|
WindowManager.mainWindow?.webContents.send("css-injected", code);
|
|
WindowManager.notificationWindow?.webContents.send("css-injected", code);
|
|
}
|
|
};
|
|
|
|
registerEvent("updateCustomTheme", updateCustomTheme);
|