Merge pull request #84 from lexisother/main

Rid ArmCord of `ts-ignore`
This commit is contained in:
smartfridge 2022-03-04 17:37:55 +01:00 committed by GitHub
commit 18bebfb421
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 76 additions and 44 deletions

View file

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

View file

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

View file

@ -8,14 +8,20 @@ const desktopCapturer = {
};
const CANCEL_ID = 'desktop-capturer-selection__cancel';
interface IPCSources {
id: string;
name: string;
thumbnail: HTMLCanvasElement;
}
export async function getDisplayMediaSelector() {
const sources = await desktopCapturer.getSources({
const sources: IPCSources[] = await desktopCapturer.getSources({
types: ['screen', 'window'],
});
return `<div class="desktop-capturer-selection__scroller">
<ul class="desktop-capturer-selection__list">
${sources
.map( //@ts-ignore i know it works
.map(
({ id, name, thumbnail }) => `
<li class="desktop-capturer-selection__item">
<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);
addStyle(screenShareCSS);
console.log("Capturer injected.")

View file

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

View file

@ -16,54 +16,58 @@ export function addScript(scriptString: string) {
script.textContent = scriptString;
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() {
console.log("Setting up temporary ArmCord settings.");
storage.set(
"settings",
{
const defaults: Settings = {
windowStyle: "default",
channel: "stable",
doneSetup: true,
armcordCSP: true,
minimizeToTray: true,
automaticPatches: false,
mods: "cumcord",
blurType: "acrylic",
}
storage.set(
"settings",
{
...defaults,
doneSetup: true,
},
function (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(
windowStyle: string,
channelSetting: string,
armcordCSPSetting: boolean,
minimizeToTray: boolean,
automaticPatches: boolean,
modsSetting: string,
blurType: string
settings: Settings
) {
console.log("Setting up ArmCord settings.");
storage.set(
"settings",
{
windowStyle: windowStyle,
channel: channelSetting,
doneSetup: true,
armcordCSP: armcordCSPSetting,
minimizeToTray: minimizeToTray,
automaticPatches: automaticPatches,
mods: modsSetting,
blurType: blurType
...settings,
doneSetup: true
},
function (error) {
if (error) throw error;