Compare commits

..

No commits in common. "8454a6d579d1c4e3060a1baf3fe5d39d1656e525" and "75276dee9069ec9a6f661bbc97a83bb056d04993" have entirely different histories.

6 changed files with 2204 additions and 60 deletions

2179
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -6,8 +6,7 @@ import "./extensions/mods";
import "./extensions/plugin"; import "./extensions/plugin";
import "./tray"; import "./tray";
import {createCustomWindow, createNativeWindow} from "./window"; import {createCustomWindow, createNativeWindow} from "./window";
import path from "path";
export var iconPath: string;
export var settings: any; export var settings: any;
export var customTitlebar: boolean; export var customTitlebar: boolean;
export var clientName: "ArmCord"; export var clientName: "ArmCord";
@ -26,11 +25,6 @@ if (process.platform == "linux") {
checkIfConfigExists(); checkIfConfigExists();
injectElectronFlags(); injectElectronFlags();
app.whenReady().then(async () => { app.whenReady().then(async () => {
if (await getConfig("customIcon") !== undefined ?? null) {
iconPath = await getConfig("customIcon")
} else {
iconPath = path.join(__dirname, "../", "/assets/ac_icon_transparent.png")
}
async function init() { async function init() {
switch (await getConfig("windowStyle")) { switch (await getConfig("windowStyle")) {
case "default": case "default":

View file

@ -1,9 +1,8 @@
import {BrowserWindow, shell, ipcMain, app, clipboard} from "electron"; import {BrowserWindow, shell, ipcMain, app, clipboard} from "electron";
import {getConfig, setConfigBulk, Settings, getLang, getVersion, getConfigLocation, getLangName, sleep} from "../utils"; import {getConfig, setConfigBulk, Settings, getLang, getVersion, getConfigLocation, getLangName} from "../utils";
import path from "path"; import path from "path";
import os from "os"; import os from "os";
import fs from "fs"; import fs from "fs";
import {mainWindow} from "../window";
var settingsWindow: BrowserWindow; var settingsWindow: BrowserWindow;
var instance: number = 0; var instance: number = 0;
const userDataPath = app.getPath("userData"); const userDataPath = app.getPath("userData");
@ -38,42 +37,19 @@ export function createSettingsWindow() {
settingsWindow.loadURL(`file://${__dirname}/settings.html`); settingsWindow.loadURL(`file://${__dirname}/settings.html`);
} }
} }
const userDataPath = app.getPath("userData");
const themesFolder = userDataPath + "/themes/";
if (!fs.existsSync(themesFolder)) {
fs.mkdirSync(themesFolder);
console.log("Created missing theme folder");
}
settingsWindow.webContents.on("did-finish-load", () => {
fs.readdirSync(themesFolder).forEach((file) => {
try {
const manifest = fs.readFileSync(`${themesFolder}/${file}/manifest.json`, "utf8");
var themeFile = JSON.parse(manifest);
settingsWindow.webContents.send(
"themeLoader",
fs.readFileSync(`${themesFolder}/${file}/${themeFile.theme}`, "utf-8")
);
console.log(`%cLoaded ${themeFile.name} made by ${themeFile.author}`, "color:red");
} catch (err) {
console.error(err);
}
});
});
ipcMain.on("saveSettings", (event, args: Settings) => { ipcMain.on("saveSettings", (event, args: Settings) => {
console.log(args); console.log(args);
setConfigBulk(args); setConfigBulk(args);
}); });
ipcMain.on("openStorageFolder", async (event) => { ipcMain.on("openStorageFolder", (event) => {
shell.openPath(storagePath); shell.openPath(storagePath);
await sleep(1000);
}); });
ipcMain.on("openThemesFolder", async (event) => { ipcMain.on("openThemesFolder", (event) => {
shell.openPath(themesPath); shell.openPath(themesPath);
await sleep(1000);
}); });
ipcMain.on("openPluginsFolder", async (event) => { ipcMain.on("openPluginsFolder", (event) => {
shell.openPath(pluginsPath); shell.openPath(pluginsPath);
await sleep(1000);
}); });
ipcMain.on("getLangName", async (event) => { ipcMain.on("getLangName", async (event) => {
event.returnValue = await getLangName(); event.returnValue = await getLangName();

View file

@ -20,12 +20,6 @@ contextBridge.exposeInMainWorld("settings", {
copyDebugInfo: () => ipcRenderer.send("copyDebugInfo") copyDebugInfo: () => ipcRenderer.send("copyDebugInfo")
}); });
if (ipcRenderer.sendSync("getLangName") == "en-US") { if (ipcRenderer.sendSync("getLangName") == "en-US") {
console.log("[Settings]: Lang " + ipcRenderer.sendSync("getLangName"));
const cssPath = path.join(__dirname, "../", "/content/css/settingsEng.css"); const cssPath = path.join(__dirname, "../", "/content/css/settingsEng.css");
document.addEventListener("DOMContentLoaded", function (event) { addStyle(fs.readFileSync(cssPath, "utf8"));
addStyle(fs.readFileSync(cssPath, "utf8"));
});
} }
ipcRenderer.on("themeLoader", (event, message) => {
addStyle(message);
});

View file

@ -99,7 +99,7 @@
<option value="stable">Stable</option> <option value="stable">Stable</option>
<option value="canary">Canary</option> <option value="canary">Canary</option>
<option value="ptb">PTB</option> <option value="ptb">PTB</option>
<option value="hummus">Hummus (unofficial, experimental)</option> <option value="hummus">Hummus (unofficial)</option>
</select> </select>
<div> <div>
<p class="header" id="settings-channel">Discord channel</p> <p class="header" id="settings-channel">Discord channel</p>

View file

@ -20,20 +20,20 @@ import startServer from "./socket";
import contextMenu from "electron-context-menu"; import contextMenu from "electron-context-menu";
import os from "os"; import os from "os";
import {tray} from "./tray"; import {tray} from "./tray";
import {iconPath} from "./main"; export var icon: string;
export let mainWindow: BrowserWindow; export let mainWindow: BrowserWindow;
export let inviteWindow: BrowserWindow; export let inviteWindow: BrowserWindow;
var osType = os.type(); var osType = os.type();
contextMenu({ contextMenu({
showSaveImageAs: true, showSaveImageAs: true,
showCopyImageAddress: true, showCopyImageAddress: true,
showSearchWithGoogle: true, showSearchWithGoogle: true
showSearchWithDuckDuckGo: true
}); });
async function doAfterDefiningTheWindow() { async function doAfterDefiningTheWindow() {
var ignoreProtocolWarning = await getConfig("ignoreProtocolWarning"); var ignoreProtocolWarning = await getConfig("ignoreProtocolWarning");
await checkIfConfigIsBroken(); checkIfConfigIsBroken();
registerIpc(); registerIpc();
if (await getConfig("mobileMode")) { if (await getConfig("mobileMode")) {
mainWindow.webContents.userAgent = mainWindow.webContents.userAgent =
@ -104,6 +104,7 @@ async function doAfterDefiningTheWindow() {
} }
getFavicon() getFavicon()
`) `)
console.log(app.getPath("temp"))
var buf = new Buffer(faviconBase64.replace(/^data:image\/\w+;base64,/, ""), 'base64'); var buf = new Buffer(faviconBase64.replace(/^data:image\/\w+;base64,/, ""), 'base64');
fs.writeFileSync(path.join(app.getPath("temp"), "/", "tray.png"), buf, "utf-8"); fs.writeFileSync(path.join(app.getPath("temp"), "/", "tray.png"), buf, "utf-8");
let trayPath = nativeImage.createFromPath(path.join(app.getPath("temp"), "/", "tray.png")); let trayPath = nativeImage.createFromPath(path.join(app.getPath("temp"), "/", "tray.png"));
@ -132,10 +133,10 @@ async function doAfterDefiningTheWindow() {
} }
}); });
}); });
await setMenu(); setMenu();
mainWindow.on("close", async (e) => { mainWindow.on("close", async (e) => {
let [width, height] = mainWindow.getSize(); let [width, height] = mainWindow.getSize();
await setWindowState({ setWindowState({
width: width, width: width,
height: height, height: height,
isMaximized: mainWindow.isMaximized() isMaximized: mainWindow.isMaximized()
@ -174,22 +175,22 @@ async function doAfterDefiningTheWindow() {
if ((await getConfig("skipSplash")) == true) { if ((await getConfig("skipSplash")) == true) {
switch (await getConfig("channel")) { switch (await getConfig("channel")) {
case "stable": case "stable":
await mainWindow.loadURL("https://discord.com/app"); mainWindow.loadURL("https://discord.com/app");
break; break;
case "canary": case "canary":
await mainWindow.loadURL("https://canary.discord.com/app"); mainWindow.loadURL("https://canary.discord.com/app");
break; break;
case "ptb": case "ptb":
await mainWindow.loadURL("https://ptb.discord.com/app"); mainWindow.loadURL("https://ptb.discord.com/app");
break; break;
case "hummus": case "hummus":
await mainWindow.loadURL("https://hummus.sys42.net/"); mainWindow.loadURL("https://hummus.sys42.net/");
break; break;
case undefined: case undefined:
await mainWindow.loadURL("https://discord.com/app"); mainWindow.loadURL("https://discord.com/app");
break; break;
default: default:
await mainWindow.loadURL("https://discord.com/app"); mainWindow.loadURL("https://discord.com/app");
} }
} else { } else {
await mainWindow.loadFile(path.join(__dirname, "/content/splash.html")); await mainWindow.loadFile(path.join(__dirname, "/content/splash.html"));
@ -202,7 +203,7 @@ export function createCustomWindow() {
height: 350, height: 350,
title: "ArmCord", title: "ArmCord",
darkTheme: true, darkTheme: true,
icon: iconPath, icon: path.join(__dirname, "../", "/assets/ac_icon_transparent.png"),
frame: false, frame: false,
autoHideMenuBar: true, autoHideMenuBar: true,
webPreferences: { webPreferences: {
@ -219,7 +220,7 @@ export function createNativeWindow() {
height: 350, height: 350,
title: "ArmCord", title: "ArmCord",
darkTheme: true, darkTheme: true,
icon: iconPath, icon: path.join(__dirname, "../", "/assets/ac_icon_transparent.png"),
frame: true, frame: true,
autoHideMenuBar: true, autoHideMenuBar: true,
webPreferences: { webPreferences: {
@ -237,7 +238,7 @@ export function createInviteWindow() {
height: 600, height: 600,
title: "ArmCord Invite Manager", title: "ArmCord Invite Manager",
darkTheme: true, darkTheme: true,
icon: iconPath, icon: path.join(__dirname, "../", "/assets/ac_icon_transparent.png"),
frame: true, frame: true,
autoHideMenuBar: true, autoHideMenuBar: true,
webPreferences: { webPreferences: {