mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-20 01:33:56 +00:00
fix: fixing stale state
This commit is contained in:
@@ -88,6 +88,7 @@ import "./themes/get-active-custom-theme";
|
||||
import "./themes/css-injector";
|
||||
import "./themes/close-editor-window";
|
||||
import "./themes/import-theme";
|
||||
import "./themes/toggle-custom-theme";
|
||||
import { isPortableVersion } from "@main/helpers";
|
||||
|
||||
ipcMain.handle("ping", () => "pong");
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Theme } from "@types";
|
||||
import { themes } from "@main/level/sublevels/themes";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { themesSublevel } from "@main/level";
|
||||
|
||||
const addCustomTheme = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
theme: Theme
|
||||
) => {
|
||||
await themes.put(theme.id, theme);
|
||||
await themesSublevel.put(theme.id, theme);
|
||||
};
|
||||
|
||||
registerEvent("addCustomTheme", addCustomTheme);
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
// import { themes } from "@main/level/sublevels/themes";
|
||||
// import { WindowManager } from "@main/services";
|
||||
// import { Theme } from "@types";
|
||||
|
||||
// export const handleDeepLinkTheme = async (
|
||||
// themeName: string,
|
||||
// authorCode: string
|
||||
// ) => {
|
||||
// const theme: Theme = {
|
||||
// id: crypto.randomUUID(),
|
||||
// name: themeName,
|
||||
// isActive: false,
|
||||
// author: authorCode,
|
||||
// authorName: "spectre",
|
||||
// code: `https://hydrathemes.shop/themes/${themeName}.css`,
|
||||
// createdAt: new Date(),
|
||||
// updatedAt: new Date(),
|
||||
// };
|
||||
|
||||
// await themes.put(theme.id, theme);
|
||||
|
||||
// const allThemes = await themes.values().all();
|
||||
// const activeTheme = allThemes.find((theme: Theme) => theme.isActive);
|
||||
|
||||
// if (activeTheme) {
|
||||
// await themes.put(activeTheme.id, {
|
||||
// ...activeTheme,
|
||||
// isActive: false,
|
||||
// });
|
||||
// }
|
||||
|
||||
// WindowManager.mainWindow?.webContents.send("css-injected", theme.code);
|
||||
|
||||
// await themes.put(theme.id, {
|
||||
// ...theme,
|
||||
// isActive: true,
|
||||
// });
|
||||
// };
|
||||
@@ -1,9 +1,8 @@
|
||||
import { themes } from "@main/level/sublevels/themes";
|
||||
import { themesSublevel } from "@main/level";
|
||||
import { registerEvent } from "../register-event";
|
||||
|
||||
const deleteAllCustomThemes = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||
console.log("sexo2");
|
||||
await themes.clear();
|
||||
await themesSublevel.clear();
|
||||
};
|
||||
|
||||
registerEvent("deleteAllCustomThemes", deleteAllCustomThemes);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { themes } from "@main/level/sublevels/themes";
|
||||
import { themesSublevel } from "@main/level";
|
||||
import { registerEvent } from "../register-event";
|
||||
|
||||
const deleteCustomTheme = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
themeId: string
|
||||
) => {
|
||||
await themes.del(themeId);
|
||||
await themesSublevel.del(themeId);
|
||||
};
|
||||
|
||||
registerEvent("deleteCustomTheme", deleteCustomTheme);
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { themesSublevel } from "@main/level";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { themes } from "@main/level/sublevels/themes";
|
||||
import { Theme } from "@types";
|
||||
|
||||
const getActiveCustomTheme = async () => {
|
||||
const allThemes = await themes.values().all();
|
||||
return allThemes.find((theme: Theme) => theme.isActive);
|
||||
const allThemes = await themesSublevel.values().all();
|
||||
return allThemes.find((theme) => theme.isActive);
|
||||
};
|
||||
|
||||
registerEvent("getActiveCustomTheme", getActiveCustomTheme);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { themes } from "@main/level/sublevels/themes";
|
||||
import { themesSublevel } from "@main/level";
|
||||
import { registerEvent } from "../register-event";
|
||||
|
||||
const getAllCustomThemes = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||
return await themes.values().all();
|
||||
return themesSublevel.values().all();
|
||||
};
|
||||
|
||||
registerEvent("getAllCustomThemes", getAllCustomThemes);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { themes } from "@main/level/sublevels/themes";
|
||||
import { themesSublevel } from "@main/level";
|
||||
import { registerEvent } from "../register-event";
|
||||
|
||||
const getCustomThemeById = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
themeId: string
|
||||
) => {
|
||||
return await themes.get(themeId);
|
||||
return themesSublevel.get(themeId);
|
||||
};
|
||||
|
||||
registerEvent("getCustomThemeById", getCustomThemeById);
|
||||
|
||||
@@ -1,13 +1,22 @@
|
||||
import { themes } from "@main/level/sublevels/themes";
|
||||
import { themesSublevel } from "@main/level";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { Theme } from "@types";
|
||||
|
||||
const updateCustomTheme = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
themeId: string,
|
||||
theme: Theme
|
||||
code: string
|
||||
) => {
|
||||
await themes.put(themeId, theme);
|
||||
const theme = await themesSublevel.get(themeId);
|
||||
|
||||
if (!theme) {
|
||||
throw new Error("Theme not found");
|
||||
}
|
||||
|
||||
await themesSublevel.put(themeId, {
|
||||
...theme,
|
||||
code,
|
||||
updatedAt: new Date(),
|
||||
});
|
||||
};
|
||||
|
||||
registerEvent("updateCustomTheme", updateCustomTheme);
|
||||
|
||||
@@ -3,3 +3,4 @@ export * from "./games";
|
||||
export * from "./game-shop-cache";
|
||||
export * from "./game-achievements";
|
||||
export * from "./keys";
|
||||
export * from "./themes";
|
||||
|
||||
@@ -2,6 +2,6 @@ import type { Theme } from "@types";
|
||||
import { db } from "../level";
|
||||
import { levelKeys } from "./keys";
|
||||
|
||||
export const themes = db.sublevel<string, Theme>(levelKeys.themes, {
|
||||
export const themesSublevel = db.sublevel<string, Theme>(levelKeys.themes, {
|
||||
valueEncoding: "json",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user