mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-09 03:37:45 +03:00
feat: close theme editor if the theme was deleted
This commit is contained in:
parent
d91d8dd26f
commit
964e9bbb2b
@ -83,6 +83,7 @@ import "./themes/open-editor-window";
|
|||||||
import "./themes/get-custom-theme-by-id";
|
import "./themes/get-custom-theme-by-id";
|
||||||
import "./themes/get-active-custom-theme";
|
import "./themes/get-active-custom-theme";
|
||||||
import "./themes/css-injector";
|
import "./themes/css-injector";
|
||||||
|
import "./themes/close-editor-window";
|
||||||
import { isPortableVersion } from "@main/helpers";
|
import { isPortableVersion } from "@main/helpers";
|
||||||
|
|
||||||
ipcMain.handle("ping", () => "pong");
|
ipcMain.handle("ping", () => "pong");
|
||||||
|
11
src/main/events/themes/close-editor-window.ts
Normal file
11
src/main/events/themes/close-editor-window.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { WindowManager } from "@main/services";
|
||||||
|
import { registerEvent } from "../register-event";
|
||||||
|
|
||||||
|
const closeEditorWindow = async (
|
||||||
|
_event: Electron.IpcMainInvokeEvent,
|
||||||
|
themeId?: string
|
||||||
|
) => {
|
||||||
|
WindowManager.closeEditorWindow(themeId);
|
||||||
|
};
|
||||||
|
|
||||||
|
registerEvent("closeEditorWindow", closeEditorWindow);
|
@ -255,6 +255,19 @@ export class WindowManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static closeEditorWindow(themeId?: string) {
|
||||||
|
if (themeId) {
|
||||||
|
const editorWindow = this.editorWindows.get(themeId);
|
||||||
|
if (editorWindow) {
|
||||||
|
editorWindow.close();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.editorWindows.forEach((editorWindow) => {
|
||||||
|
editorWindow.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static redirect(hash: string) {
|
public static redirect(hash: string) {
|
||||||
if (!this.mainWindow) this.createMainWindow();
|
if (!this.mainWindow) this.createMainWindow();
|
||||||
this.loadMainWindowURL(hash);
|
this.loadMainWindowURL(hash);
|
||||||
|
@ -358,4 +358,6 @@ contextBridge.exposeInMainWorld("electron", {
|
|||||||
ipcRenderer.on("css-injected", listener);
|
ipcRenderer.on("css-injected", listener);
|
||||||
return () => ipcRenderer.removeListener("css-injected", listener);
|
return () => ipcRenderer.removeListener("css-injected", listener);
|
||||||
},
|
},
|
||||||
|
closeEditorWindow: (themeId?: string) =>
|
||||||
|
ipcRenderer.invoke("closeEditorWindow", themeId),
|
||||||
});
|
});
|
||||||
|
1
src/renderer/src/declaration.d.ts
vendored
1
src/renderer/src/declaration.d.ts
vendored
@ -285,6 +285,7 @@ declare global {
|
|||||||
onCssInjected: (
|
onCssInjected: (
|
||||||
cb: (cssString: string) => void
|
cb: (cssString: string) => void
|
||||||
) => () => Electron.IpcRenderer;
|
) => () => Electron.IpcRenderer;
|
||||||
|
closeEditorWindow: (themeId?: string) => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Window {
|
interface Window {
|
||||||
|
@ -25,6 +25,7 @@ export const DeleteAllThemesModal = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
await window.electron.deleteAllCustomThemes();
|
await window.electron.deleteAllCustomThemes();
|
||||||
|
await window.electron.closeEditorWindow();
|
||||||
onClose();
|
onClose();
|
||||||
onThemesDeleted();
|
onThemesDeleted();
|
||||||
};
|
};
|
||||||
|
@ -29,6 +29,7 @@ export const DeleteThemeModal = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
await window.electron.deleteCustomTheme(themeId);
|
await window.electron.deleteCustomTheme(themeId);
|
||||||
|
await window.electron.closeEditorWindow(themeId);
|
||||||
onThemeDeleted();
|
onThemeDeleted();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user