Compare commits

...

9 commits

Author SHA1 Message Date
smartfrigde
eb1e908b69 v3.0.2 2022-01-16 21:40:14 +01:00
smartfrigde
414dbb4f55 maybe not 2022-01-16 21:40:03 +01:00
smartfrigde
6d2831d5c7 i broke linux 2022-01-16 21:39:04 +01:00
smartfrigde
9fbfc778cc v3.0.2 2022-01-16 21:31:36 +01:00
smartfrigde
883bee6236 Fix Windows 2022-01-16 21:31:03 +01:00
smartfrigde
92a452cea4 v3.0.1 2022-01-16 19:14:57 +01:00
smartfrigde
3c4056a0fc Add titlebar related stuff to context bridge 2022-01-16 19:14:26 +01:00
smartfrigde
b1c9631c95 Merge branch 'main' of https://github.com/armcord/armcord 2022-01-16 19:09:03 +01:00
smartfrigde
0d55c30810 Fix ArmCord not starting 2022-01-16 19:07:00 +01:00
5 changed files with 75 additions and 52 deletions

View file

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

View file

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

View file

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

View file

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

View file

@ -1,5 +1,7 @@
import * as fs from "fs";
import * as storage from "electron-json-storage";
import * as fs from "fs";
import { app } from "electron";
//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) {
const style = document.createElement("style");
@ -21,6 +23,7 @@ export function setup() {
channel: "stable",
firstRun: "done",
armcordCSP: true,
mods: "cumcord"
},
function (error) {
if (error) throw error;
@ -51,8 +54,16 @@ export function saveSettings(
}
);
}
export function getVersion() {
const pkgjson = fs.readFileSync("./package.json", "utf8");
return JSON.parse(pkgjson).version;
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';
}