mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
Make theme quick acions functional
This commit is contained in:
parent
610931d75b
commit
b06d4a4810
2 changed files with 20 additions and 15 deletions
|
@ -154,6 +154,18 @@ export function createTManagerWindow(): void {
|
|||
fs.writeFileSync(path.join(userDataPath, "/disabled.txt"), e.replace(name, ""));
|
||||
sleep(1000);
|
||||
});
|
||||
ipcMain.on("uninstallTheme", async (_event, id: string) => {
|
||||
let themePath = path.join(themesFolder, id);
|
||||
if (fs.existsSync(themePath)) {
|
||||
fs.rmdirSync(themePath, {recursive: true});
|
||||
console.log(`Removed ${id} folder`);
|
||||
} else if (fs.existsSync(path.join(themesFolder, `${id}-BD`))) {
|
||||
fs.rmdirSync(path.join(themesFolder, `${id}-BD`), {recursive: true});
|
||||
console.log(`Removed ${id} folder`);
|
||||
}
|
||||
themeWindow.webContents.reload();
|
||||
mainWindow.webContents.reload();
|
||||
});
|
||||
ipcMain.on("installBDTheme", async (_event, link: string) => {
|
||||
try {
|
||||
let code = await (await fetch(link)).text();
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
import {ipcRenderer} from "electron";
|
||||
import {ipcRenderer, contextBridge} from "electron";
|
||||
import {sleep} from "../utils";
|
||||
contextBridge.exposeInMainWorld("themes", {
|
||||
install: (url: string) => ipcRenderer.send("installBDTheme", url),
|
||||
uninstall: (id: string) => ipcRenderer.send("uninstallTheme", id)
|
||||
});
|
||||
ipcRenderer.on("themeManifest", (_event, json) => {
|
||||
let manifest = JSON.parse(json);
|
||||
console.log(manifest);
|
||||
|
@ -26,9 +30,9 @@ ipcRenderer.on("themeManifest", (_event, json) => {
|
|||
if (manifest.supportsArmCordTitlebar !== undefined) {
|
||||
document.getElementById(
|
||||
"themeInfoButtons"
|
||||
)!.innerHTML += `<img class="themeInfoIcon" id="removeTheme" alt="Remove the theme" src="https://raw.githubusercontent.com/ArmCord/BrandingStuff/main/Trash.png"></img>
|
||||
<img class="themeInfoIcon" id="updateTheme" alt="Update your theme" src="https://raw.githubusercontent.com/ArmCord/BrandingStuff/main/UpgradeArrow.png"></img>
|
||||
<img class="themeInfoIcon" id="compatibility" alt="Supports ArmCord Titlebar" src=""></img>`;
|
||||
)!.innerHTML += `<img class="themeInfoIcon" id="removeTheme" onclick="themes.uninstall('${id}')" title="Remove the theme" src="https://raw.githubusercontent.com/ArmCord/BrandingStuff/main/Trash.png"></img>
|
||||
<img class="themeInfoIcon" id="updateTheme" onclick="themes.install('${manifest.updateSrc}')" title="Update your theme" src="https://raw.githubusercontent.com/ArmCord/BrandingStuff/main/UpgradeArrow.png"></img>
|
||||
<img class="themeInfoIcon" id="compatibility" title="Supports ArmCord Titlebar" src=""></img>`;
|
||||
console.log("e");
|
||||
if (manifest.supportsArmCordTitlebar == true) {
|
||||
(document.getElementById(`compatibility`) as HTMLImageElement).src =
|
||||
|
@ -37,17 +41,6 @@ ipcRenderer.on("themeManifest", (_event, json) => {
|
|||
(document.getElementById(`compatibility`) as HTMLImageElement).src =
|
||||
"https://raw.githubusercontent.com/ArmCord/BrandingStuff/main/WindowUnsupported.png";
|
||||
}
|
||||
document.getElementById("removeTheme")!.addEventListener("click", () => {
|
||||
ipcRenderer.send("", id + "-BD");
|
||||
document.getElementById("themeInfoModal")!.style.display = "none";
|
||||
document.getElementById("themeInfoButtons")!.innerHTML = "";
|
||||
});
|
||||
document.getElementById(`updateTheme`)!.addEventListener("click", () => {
|
||||
console.log("Updating " + manifest.name);
|
||||
ipcRenderer.send("installBDTheme", manifest.updateSrc);
|
||||
document.getElementById("themeInfoModal")!.style.display = "none";
|
||||
document.getElementById("themeInfoButtons")!.innerHTML = "";
|
||||
});
|
||||
}
|
||||
if (manifest.source != undefined)
|
||||
document.getElementById(
|
||||
|
|
Loading…
Reference in a new issue