Compare commits

..

No commits in common. "eb1e908b691d6a1c155db825aaccb98863dc0c02" and "678577f0ebb4830f22a777b281234a0297caceb6" have entirely different histories.

5 changed files with 51 additions and 74 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "ArmCord", "name": "ArmCord",
"version": "3.0.2", "version": "3.0.0",
"description": "ArmCord is a custom client designed to enhance your Discord experience while keeping everything lightweight.", "description": "ArmCord is a custom client designed to enhance your Discord experience while keeping everything lightweight.",
"main": "ts-out/main.js", "main": "ts-out/main.js",
"scripts": { "scripts": {

View file

@ -1,22 +1,17 @@
// Modules to control application life and create native browser window // Modules to control application life and create native browser window
import { import { app, BrowserWindow, ipcMain, shell, desktopCapturer, session } from "electron";
app,
BrowserWindow,
ipcMain,
shell,
desktopCapturer,
session,
} from "electron";
import * as path from "path"; import * as path from "path";
import "v8-compile-cache"; import "v8-compile-cache";
import * as storage from "electron-json-storage"; import * as storage from "electron-json-storage";
import { saveSettings, getVersion, setup, getConfigUnsafe } from "./utils"; import { saveSettings, getVersion, setup } from "./utils";
import "./extensions/mods"; import "./extensions/mods";
import "./extensions/plugin"; import "./extensions/plugin";
import "./tray"; import "./tray";
import "./shortcuts"; import "./shortcuts";
var contentPath: string; var contentPath: string = "null";
var frame: boolean;
var channel: string; var channel: string;
var titlebar: boolean;
export var mainWindow: BrowserWindow; export var mainWindow: BrowserWindow;
var settings: any; var settings: any;
@ -35,21 +30,22 @@ storage.has("settings", function (error, hasKey) {
storage.get("settings", function (error, data: any) { storage.get("settings", function (error, data: any) {
if (error) throw error; if (error) throw error;
console.log(data); console.log(data);
titlebar = data.customTitlebar;
channel = data.channel; channel = data.channel;
settings = data; settings = data;
if ((titlebar = true)) {
frame = false;
} else {
frame = true;
}
}); });
var titlebar:any = getConfigUnsafe("customTitlebar")
console.log(!titlebar)
function createWindow() { function createWindow() {
mainWindow = new BrowserWindow({ mainWindow = new BrowserWindow({
width: 300, width: 300,
height: 350, height: 350,
title: "ArmCord", title: "ArmCord",
darkTheme: true, icon: "./assets/ac_icon_transparent.png",
icon: path.join(__dirname, "/assets/icon_transparent.png"), frame: frame,
frame: !titlebar,
autoHideMenuBar: true,
webPreferences: { webPreferences: {
preload: path.join(__dirname, "preload/preload.js"), preload: path.join(__dirname, "preload/preload.js"),
}, },
@ -85,8 +81,9 @@ function createWindow() {
mainWindow.setSize(800, 600); mainWindow.setSize(800, 600);
}); });
ipcMain.on("restart", (event, arg) => { ipcMain.on("restart", (event, arg) => {
app.relaunch(); app.relaunch();
app.exit(); app.exit();
}); });
ipcMain.on("saveSettings", (event, ...args) => { ipcMain.on("saveSettings", (event, ...args) => {
@ -119,43 +116,38 @@ function createWindow() {
shell.openExternal(url); shell.openExternal(url);
return { action: "deny" }; return { action: "deny" };
}); });
console.log(contentPath)
try { mainWindow.loadFile(contentPath);
mainWindow.loadFile(contentPath);
} catch(e) {
console.log("Major error detected while starting up. User is most likely on Windows platform. Fallback to alternative startup.")
mainWindow.loadURL(`file://${__dirname}/content/splash.html`);
}
} }
app.whenReady().then(() => { app.whenReady().then(() => {
createWindow(); createWindow();
session session
.fromPartition("some-partition") .fromPartition("some-partition")
.setPermissionRequestHandler((webContents, permission, callback) => { .setPermissionRequestHandler((webContents, permission, callback) => {
const url = webContents.getURL(); //unused? const url = webContents.getURL(); //unused?
if (permission === "notifications") { if (permission === "notifications") {
// Approves the permissions request // Approves the permissions request
callback(true); callback(true);
} }
if (permission === "media") { if (permission === "media") {
// Approves the permissions request // Approves the permissions request
callback(true); callback(true);
} }
if (url.startsWith("discord://")) { if (url.startsWith("discord://")) {
// Denies the permissions request // Denies the permissions request
return callback(false); return callback(false);
} }
if (url.startsWith("discord.com/science")) { if (url.startsWith("discord.com/science")) {
// Denies the permissions request // Denies the permissions request
return callback(false); return callback(false);
} }
if (url.startsWith("discord.com/tracing")) { if (url.startsWith("discord.com/tracing")) {
// Denies the permissions request // Denies the permissions request
return callback(false); return callback(false);
} }
}); });
app.on("activate", function () { app.on("activate", function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow(); if (BrowserWindow.getAllWindows().length === 0) createWindow();
}); });

View file

@ -1,6 +1,6 @@
import { contextBridge, ipcRenderer } from "electron"; import { contextBridge, ipcRenderer } from "electron";
import { getDisplayMediaSelector } from "./capturer"; import { getDisplayMediaSelector } from "./capturer";
import { injectTitlebar } from "./titlebar";
contextBridge.exposeInMainWorld("armcord", { contextBridge.exposeInMainWorld("armcord", {
window: { window: {
@ -9,9 +9,6 @@ contextBridge.exposeInMainWorld("armcord", {
minimize: () => ipcRenderer.send("win-minimize"), minimize: () => ipcRenderer.send("win-minimize"),
maximize: () => ipcRenderer.send("win-maximize"), maximize: () => ipcRenderer.send("win-maximize"),
}, },
titlebar: {
injectTitlebar: () => injectTitlebar(),
},
electron: process.versions.electron, electron: process.versions.electron,
channel: ipcRenderer.sendSync("channel"), channel: ipcRenderer.sendSync("channel"),
version: ipcRenderer.sendSync("get-app-version", "app-version"), version: ipcRenderer.sendSync("get-app-version", "app-version"),

View file

@ -1,9 +1,8 @@
import { app, Menu, Tray } from 'electron'; import { app, Menu, Tray } from 'electron';
import {mainWindow} from './main'; import {mainWindow} from './main';
import * as path from 'path'
let tray = null let tray = null
app.whenReady().then(() => { app.whenReady().then(() => {
tray = new Tray(path.join(__dirname, "../", "/assets/ac_plug.png")) tray = new Tray('./assets/ac_plug.png')
const contextMenu = Menu.buildFromTemplate([ const contextMenu = Menu.buildFromTemplate([
{ {
label: "Open ArmCord", label: "Open ArmCord",
@ -26,6 +25,6 @@ app.whenReady().then(() => {
}, },
]); ]);
tray.setToolTip('ArmCord ' + process.env.npm_package_version) tray.setToolTip('ArmCord' + process.env.npm_package_version)
tray.setContextMenu(contextMenu) tray.setContextMenu(contextMenu)
}) })

View file

@ -1,7 +1,5 @@
import * as storage from "electron-json-storage";
import * as fs from "fs"; import * as fs from "fs";
import { app } from "electron"; import * as storage from "electron-json-storage";
//utillity functions that are used all over the codebase or just too obscure to be put in the file used in //utillity functions that are used all over the codebase or just too obscure to be put in the file used in
export function addStyle(styleString: string) { export function addStyle(styleString: string) {
const style = document.createElement("style"); const style = document.createElement("style");
@ -23,7 +21,6 @@ export function setup() {
channel: "stable", channel: "stable",
firstRun: "done", firstRun: "done",
armcordCSP: true, armcordCSP: true,
mods: "cumcord"
}, },
function (error) { function (error) {
if (error) throw error; if (error) throw error;
@ -54,16 +51,8 @@ export function saveSettings(
} }
); );
} }
export async function getConfigUnsafe(object: string) {
const userDataPath = app.getPath("userData");
const storagePath = userDataPath + "/storage/";
let rawdata = fs.readFileSync(storagePath + "settings.json", "utf-8");
let returndata = JSON.parse(rawdata);
console.log(returndata[object]);
return returndata[object]
}
export function getVersion() {
//to-do better way of doing this
return '3.0.1';
}
export function getVersion() {
const pkgjson = fs.readFileSync("./package.json", "utf8");
return JSON.parse(pkgjson).version;
}