mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
fix titlebar loading
solves https://github.com/ArmCord/ArmCord/issues/616
This commit is contained in:
parent
69c34435f2
commit
3f7b154068
2 changed files with 4 additions and 48 deletions
|
@ -5,7 +5,7 @@ import {ipcRenderer} from "electron";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import {injectMobileStuff} from "./mobile.js";
|
import {injectMobileStuff} from "./mobile.js";
|
||||||
import {fixTitlebar, injectTitlebar} from "./titlebar.mjs";
|
import {injectTitlebar} from "./titlebar.mjs";
|
||||||
import {injectSettings} from "./settings.js";
|
import {injectSettings} from "./settings.js";
|
||||||
import {addStyle, addScript} from "../../common/dom.js";
|
import {addStyle, addScript} from "../../common/dom.js";
|
||||||
import {sleep} from "../../common/sleep.js";
|
import {sleep} from "../../common/sleep.js";
|
||||||
|
@ -27,7 +27,6 @@ function updateLang(): void {
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
// REVIEW - Assumption, this was previously any
|
|
||||||
armcord: ArmCordWindow;
|
armcord: ArmCordWindow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +72,7 @@ setInterval(() => {
|
||||||
if (document.getElementById("window-controls-container") == null) {
|
if (document.getElementById("window-controls-container") == null) {
|
||||||
console.warn("Titlebar didn't inject, retrying...");
|
console.warn("Titlebar didn't inject, retrying...");
|
||||||
if (ipcRenderer.sendSync("titlebar")) {
|
if (ipcRenderer.sendSync("titlebar")) {
|
||||||
fixTitlebar();
|
//fixTitlebar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addScript(`
|
addScript(`
|
||||||
|
|
|
@ -4,7 +4,7 @@ import fs from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import os from "os";
|
import os from "os";
|
||||||
export function injectTitlebar(): void {
|
export function injectTitlebar(): void {
|
||||||
document.addEventListener("DOMContentLoaded", function (_event) {
|
window.onload = function () {
|
||||||
const elem = document.createElement("div");
|
const elem = document.createElement("div");
|
||||||
elem.innerHTML = `<nav class="titlebar">
|
elem.innerHTML = `<nav class="titlebar">
|
||||||
<div class="window-title" id="window-title"></div>
|
<div class="window-title" id="window-title"></div>
|
||||||
|
@ -61,48 +61,5 @@ export function injectTitlebar(): void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
};
|
||||||
}
|
|
||||||
|
|
||||||
export function fixTitlebar(): void {
|
|
||||||
const elem = document.createElement("div");
|
|
||||||
elem.innerHTML = `<nav class="titlebar">
|
|
||||||
<div class="window-title" id="window-title"></div>
|
|
||||||
<div id="window-controls-container">
|
|
||||||
<div id="spacer"></div>
|
|
||||||
<div id="minimize"><div id="minimize-icon"></div></div>
|
|
||||||
<div id="maximize"><div id="maximize-icon"></div></div>
|
|
||||||
<div id="quit"><div id="quit-icon"></div></div>
|
|
||||||
</div>
|
|
||||||
</nav>`;
|
|
||||||
elem.classList.add("withFrame-haYltI");
|
|
||||||
if (document.getElementById("app-mount") == null) {
|
|
||||||
document.body.appendChild(elem);
|
|
||||||
} else {
|
|
||||||
document.getElementById("app-mount")!.prepend(elem);
|
|
||||||
}
|
|
||||||
const minimize = document.getElementById("minimize");
|
|
||||||
const maximize = document.getElementById("maximize");
|
|
||||||
const quit = document.getElementById("quit");
|
|
||||||
|
|
||||||
minimize!.addEventListener("click", () => {
|
|
||||||
ipcRenderer.send("win-minimize");
|
|
||||||
});
|
|
||||||
|
|
||||||
maximize!.addEventListener("click", () => {
|
|
||||||
if (ipcRenderer.sendSync("win-isMaximized") == true) {
|
|
||||||
ipcRenderer.send("win-unmaximize");
|
|
||||||
document.body.removeAttribute("isMaximized");
|
|
||||||
} else if (ipcRenderer.sendSync("win-isNormal") == true) {
|
|
||||||
ipcRenderer.send("win-maximize");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
quit!.addEventListener("click", () => {
|
|
||||||
if (ipcRenderer.sendSync("minimizeToTray") === true) {
|
|
||||||
ipcRenderer.send("win-hide");
|
|
||||||
} else if (ipcRenderer.sendSync("minimizeToTray") === false) {
|
|
||||||
ipcRenderer.send("win-quit");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue