Rid ArmCord of ts-ignore

This commit is contained in:
Alyxia Sother 2022-03-04 17:30:23 +01:00
parent bab60a4f1b
commit 7ed9f1bef2
No known key found for this signature in database
GPG key ID: 355968D14144B739
5 changed files with 76 additions and 44 deletions

View file

@ -43,7 +43,15 @@
} else { } else {
console.log("Starting ArmCord Setup..."); console.log("Starting ArmCord Setup...");
document.getElementById("express").addEventListener("click", function () { document.getElementById("express").addEventListener("click", function () {
window.armcordinternal.saveSettings("default", "stable", true, true, false, "cumcord", "acrylic"); window.armcordinternal.saveSettings({
windowStyle: "default",
channel: "stable",
armcordCSP: true,
minimizeToTray: true,
automaticPatches: false,
mods: "cumcord",
blurType: "acrylic"
})
fade(document.getElementById("setup")); fade(document.getElementById("setup"));
setTimeout(function () { setTimeout(function () {
window.armcordinternal.restart() window.armcordinternal.restart()
@ -91,15 +99,30 @@
.getElementById("next") .getElementById("next")
.addEventListener("click", function () { .addEventListener("click", function () {
var mod = document.getElementById("mod").value; var mod = document.getElementById("mod").value;
window.armcordinternal.saveSettings("default", branch, true,true,false, mod, "acrylic"); window.armcordinternal.saveSettings({
windowStyle: "default",
channel: branch,
armcordCSP: true,
minimizeToTray: true,
automaticPatches: false,
mods: mod,
blurType: "acrylic"
})
fade(document.getElementById("setup")); fade(document.getElementById("setup"));
setTimeout(function () { setTimeout(function () {
window.armcordinternal.restart(); window.armcordinternal.restart();
}, 5000); }, 5000);
}); });
} else { } else {
//saveSettings(windowStyle: string, channelSetting: string, armcordCSPSetting: boolean, minimizeToTray:boolean, modsSetting: string) window.armcordinternal.saveSettings({
window.armcordinternal.saveSettings("default", branch, true,true,false, "none", "acrylic"); windowStyle: "default",
channel: branch,
armcordCSP: true,
minimizeToTray: true,
automaticPatches: false,
mods: "none",
blurType: "acrylic"
})
fade(document.getElementById("setup")); fade(document.getElementById("setup"));
setTimeout(function () { setTimeout(function () {
window.armcordinternal.restart() window.armcordinternal.restart()

View file

@ -45,9 +45,8 @@ export function registerIpc() {
app.relaunch(); app.relaunch();
app.exit(); app.exit();
}); });
ipcMain.on("saveSettings", (event, ...args) => { ipcMain.on("saveSettings", (event, args) => {
//@ts-ignore saveSettings(args);
saveSettings(...args);
}); });
ipcMain.on("minimizeToTray", (event) => { ipcMain.on("minimizeToTray", (event) => {
console.log(settings.minimizeToTray); console.log(settings.minimizeToTray);

View file

@ -8,14 +8,20 @@ const desktopCapturer = {
}; };
const CANCEL_ID = 'desktop-capturer-selection__cancel'; const CANCEL_ID = 'desktop-capturer-selection__cancel';
interface IPCSources {
id: string;
name: string;
thumbnail: HTMLCanvasElement;
}
export async function getDisplayMediaSelector() { export async function getDisplayMediaSelector() {
const sources = await desktopCapturer.getSources({ const sources: IPCSources[] = await desktopCapturer.getSources({
types: ['screen', 'window'], types: ['screen', 'window'],
}); });
return `<div class="desktop-capturer-selection__scroller"> return `<div class="desktop-capturer-selection__scroller">
<ul class="desktop-capturer-selection__list"> <ul class="desktop-capturer-selection__list">
${sources ${sources
.map( //@ts-ignore i know it works .map(
({ id, name, thumbnail }) => ` ({ id, name, thumbnail }) => `
<li class="desktop-capturer-selection__item"> <li class="desktop-capturer-selection__item">
<button class="desktop-capturer-selection__btn" data-id="${id}" title="${name}"> <button class="desktop-capturer-selection__btn" data-id="${id}" title="${name}">
@ -148,7 +154,7 @@ window.navigator.mediaDevices.getDisplayMedia = () => new Promise(async (resolve
}); });
`; `;
document.addEventListener("DOMContentLoaded", function(event) { document.addEventListener("DOMContentLoaded", function() {
addScript(screenShareJS); addScript(screenShareJS);
addStyle(screenShareCSS); addStyle(screenShareCSS);
console.log("Capturer injected.") console.log("Capturer injected.")

View file

@ -1,6 +1,6 @@
import { BrowserWindow, shell, ipcMain } from "electron"; import { BrowserWindow, shell, ipcMain } from "electron";
import * as storage from "electron-json-storage"; import * as storage from "electron-json-storage";
import {getConfigUnsafe, saveSettings} from "../utils"; import {getConfigUnsafe, saveSettings, Settings} from "../utils";
import path from "path"; import path from "path";
var settings:any; var settings:any;
var isAlreadyCreated:boolean = false; var isAlreadyCreated:boolean = false;
@ -25,9 +25,9 @@ export function createSettingsWindow() {
preload: path.join(__dirname, "preload.js"), preload: path.join(__dirname, "preload.js"),
}, },
}); });
ipcMain.on("saveSettings", (event, ...args) => { ipcMain.on("saveSettings", (event, args: Settings) => {
//@ts-ignore console.log(args);
saveSettings(...args); saveSettings(args);
}); });
ipcMain.handle("getSetting", (event, toGet: string) => { ipcMain.handle("getSetting", (event, toGet: string) => {
return getConfigUnsafe(toGet); return getConfigUnsafe(toGet);

View file

@ -16,54 +16,58 @@ export function addScript(scriptString: string) {
script.textContent = scriptString; script.textContent = scriptString;
document.body.append(script); document.body.append(script);
} }
export async function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
export async function checkIfConfigIsNew() {
if (await getConfigUnsafe("automaticPatches") == undefined) {
firstRun = true;
}
}
export interface Settings {
windowStyle: string,
channel: string,
armcordCSP: boolean,
minimizeToTray: boolean,
automaticPatches: boolean,
mods: string,
blurType: string
}
export function setup() { export function setup() {
console.log("Setting up temporary ArmCord settings."); console.log("Setting up temporary ArmCord settings.");
const defaults: Settings = {
windowStyle: "default",
channel: "stable",
armcordCSP: true,
minimizeToTray: true,
automaticPatches: false,
mods: "cumcord",
blurType: "acrylic",
}
storage.set( storage.set(
"settings", "settings",
{ {
windowStyle: "default", ...defaults,
channel: "stable",
doneSetup: true, doneSetup: true,
armcordCSP: true,
minimizeToTray: true,
automaticPatches: false,
mods: "cumcord",
blurType: "acrylic",
}, },
function (error) { function (error) {
if (error) throw error; if (error) throw error;
} }
); );
} }
export async function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
export async function checkIfConfigIsNew() {
if (await getConfigUnsafe("automaticPatches") == undefined) {
firstRun = true;
}
}
export function saveSettings( export function saveSettings(
windowStyle: string, settings: Settings
channelSetting: string,
armcordCSPSetting: boolean,
minimizeToTray: boolean,
automaticPatches: boolean,
modsSetting: string,
blurType: string
) { ) {
console.log("Setting up ArmCord settings."); console.log("Setting up ArmCord settings.");
storage.set( storage.set(
"settings", "settings",
{ {
windowStyle: windowStyle, ...settings,
channel: channelSetting, doneSetup: true
doneSetup: true,
armcordCSP: armcordCSPSetting,
minimizeToTray: minimizeToTray,
automaticPatches: automaticPatches,
mods: modsSetting,
blurType: blurType
}, },
function (error) { function (error) {
if (error) throw error; if (error) throw error;