Add portable mode (#280)

This commit is contained in:
Remty5 2022-12-03 17:21:25 +01:00 committed by GitHub
parent 52b1ff77f8
commit 378fef1a0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View file

@ -1,7 +1,7 @@
// Modules to control application life and create native browser window
import {app, BrowserWindow, session} from "electron";
import "v8-compile-cache";
import {getConfig, checkIfConfigExists, injectElectronFlags, installModLoader} from "./utils";
import {checkForDataFolder, getConfig, checkIfConfigExists, injectElectronFlags, installModLoader} from "./utils";
import "./extensions/mods";
import "./tray";
import {createCustomWindow, createNativeWindow, createTransparentWindow, mainWindow} from "./window";
@ -22,6 +22,7 @@ if (process.platform == "linux") {
}
}
}
checkForDataFolder();
checkIfConfigExists();
injectElectronFlags();
app.whenReady().then(async () => {

View file

@ -1,5 +1,6 @@
import {BrowserWindow, shell, ipcMain, app, clipboard} from "electron";
import {
checkForDataFolder,
getConfig,
setConfigBulk,
Settings,
@ -16,6 +17,7 @@ import fs from "fs";
import {mainWindow} from "../window";
var settingsWindow: BrowserWindow;
var instance: number = 0;
checkForDataFolder();
const userDataPath = app.getPath("userData");
const storagePath = path.join(userDataPath, "/storage/");
const themesPath = path.join(userDataPath, "/themes/");

View file

@ -222,6 +222,14 @@ export async function getWindowState(object: string) {
}
//ArmCord Settings/Storage manager
export function checkForDataFolder() {
const dataPath = path.join(path.dirname(app.getPath("exe")), "armcord-data");
if (fs.existsSync(dataPath) && fs.statSync(dataPath).isDirectory()) {
console.log("Found armcord-data folder. Running in portable mode.");
app.setPath("userData", dataPath);
}
}
export interface Settings {
windowStyle: string;
channel: string;