Skip to content
This repository has been archived by the owner on Dec 14, 2024. It is now read-only.

Commit

Permalink
✨ Add config options
Browse files Browse the repository at this point in the history
Add config option to disable SSL check
Add config option to enable experimental improved multi instance support
  • Loading branch information
OmegaRogue committed Jan 22, 2024
1 parent 8168bc3 commit d4ea938
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
4 changes: 3 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
"background": "",
"backgroundColor": "#003049ff",
"textColor": "#eae2b7ff",
"accentColor": "#f77f00ff"
"accentColor": "#f77f00ff",
"ignoreCertificateErrors": false,
"experimentalMultiInstance": false
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vtt-desktop-client",
"packageManager": "yarn@1.22.19",
"version": "1.5.0-alpha7",
"version": "1.5.0-alpha8",
"license": "MIT",
"description": "VTT Desktop Client",
"main": ".vite/build/main.js",
Expand Down
31 changes: 25 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// noinspection ES6MissingAwait,JSIgnoredPromiseFromCall

import {app, BrowserWindow, ipcMain, safeStorage,} from 'electron';
import {app, BrowserWindow, ipcMain, safeStorage, session} from 'electron';
import path from 'path';
import fs from 'fs';

Expand Down Expand Up @@ -44,16 +44,30 @@ if (!isSingleInstance) {

const windowsData = {} as WindowsData;

let partitionId: number = 0;

function getSession(): Electron.Session {
if (!getAppConfig().experimentalMultiInstance) return session.defaultSession;
const partitionIdTemp = partitionId;
partitionId++
if (partitionIdTemp == 0)
return session.defaultSession;
return session.fromPartition(`persist:${partitionIdTemp}`, {cache: true});
}

// let win: BrowserWindow;

function createWindow(): BrowserWindow {
const localSession = getSession();
let window = new BrowserWindow({
show: false, width: 800, height: 600, webPreferences: {
preload: path.join(__dirname, "preload.js"),
nodeIntegration: false,
contextIsolation: true,
webgl: true
webgl: true,
session: localSession
},

});

// Fix Popouts
Expand Down Expand Up @@ -228,14 +242,20 @@ ipcMain.handle("get-user-data", (_, gameId: GameId) => getLoginDetails(gameId))

ipcMain.handle("app-version", () => app.getVersion())

ipcMain.handle("app-config", () => {
function getAppConfig(): AppConfig {
try {
const json = fs.readFileSync(path.join(app.getAppPath(), "config.json")).toString();
return JSON.parse(json) as AppConfig;
const appConfig = JSON.parse(json) as AppConfig;
if (appConfig.ignoreCertificateErrors) {
app.commandLine.appendSwitch("ignore-certificate-errors");
}
return appConfig;
} catch (e) {
return {} as AppConfig;
}
});
}

ipcMain.handle("app-config", getAppConfig);

ipcMain.handle("select-path", (e) => {
windowsData[e.sender.id].autoLogin = true;
Expand All @@ -262,7 +282,6 @@ ipcMain.on("return-select", (e) => {
});



app.on('activate', (_, hasVisibleWindows) => {
if (!hasVisibleWindows) {
createWindow();
Expand Down
1 change: 0 additions & 1 deletion src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ async function createGameList() {
value.remove();
}
);

const gameList = window.localStorage.getItem("gameList") || "[]";
let gameListJson: GameConfig[] = JSON.parse(gameList);
gameListJson = [...config.games, ...gameListJson];
Expand Down
2 changes: 2 additions & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ type AppConfig = {
cachePath?: string;
autoCacheClear?: boolean;
customCSS?: string;
ignoreCertificateErrors?: boolean;
experimentalMultiInstance?: boolean;
}


Expand Down

0 comments on commit d4ea938

Please sign in to comment.