mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2025-08-05 12:26:41 +02:00
fixed feature flag parsing & setting
This commit is contained in:
41
src/features/flags/flags.ts
Normal file
41
src/features/flags/flags.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { App } from "electron";
|
||||
import { flags } from "../../constants/flags";
|
||||
import { settings } from "../../constants/settings";
|
||||
import { settingsStore } from "../../scripts/settings";
|
||||
import { Logger } from "../logger";
|
||||
|
||||
/**
|
||||
* Set default Electron flags
|
||||
*/
|
||||
export function setDefaultFlags(app: App) {
|
||||
setFlag(app, "disable-seccomp-filter-sandbox");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Tidal's managed flags from the user settings
|
||||
* @param app
|
||||
*/
|
||||
export function setManagedFlagsFromSettings(app: App) {
|
||||
const flagsFromSettings = settingsStore.get(settings.flags.root);
|
||||
if (flagsFromSettings) {
|
||||
for (const [key, value] of Object.entries(flagsFromSettings)) {
|
||||
if (value) {
|
||||
const { flag, value } = flags[key];
|
||||
|
||||
Logger.log(`enabling command line option ${flag} with value ${value}`);
|
||||
setFlag(app, flag, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a single flag for Electron
|
||||
* @param app app to set it on
|
||||
* @param flag flag name
|
||||
* @param value value to be set for the flag
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function setFlag(app: App, flag: string, value?: any) {
|
||||
app.commandLine.appendSwitch(flag, value);
|
||||
}
|
Reference in New Issue
Block a user