mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2024-11-22 13:32:42 +01:00
fixed feature flag parsing & setting
This commit is contained in:
parent
c7931cf913
commit
4b81378423
@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [next]
|
## [next]
|
||||||
|
|
||||||
|
- Fixed: config flags not being set correctly
|
||||||
- [DEV]:
|
- [DEV]:
|
||||||
- Logger is now static and will automatically call either ipcRenderer or ipcMain
|
- Logger is now static and will automatically call either ipcRenderer or ipcMain
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
export const flags: { [key: string]: { flag: string; value?: string }[] } = {
|
export const flags: { [key: string]: { flag: string; value?: string } } = {
|
||||||
gpuRasterization: [{ flag: "enable-gpu-rasterization", value: undefined }],
|
gpuRasterization: { flag: "enable-gpu-rasterization", value: undefined },
|
||||||
disableHardwareMediaKeys: [{ flag: "disable-features", value: "HardwareMediaKeyHandling" }],
|
disableHardwareMediaKeys: { flag: "disable-features", value: "HardwareMediaKeyHandling" },
|
||||||
};
|
};
|
||||||
|
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);
|
||||||
|
}
|
40
src/main.ts
40
src/main.ts
@ -9,9 +9,13 @@ import {
|
|||||||
session,
|
session,
|
||||||
} from "electron";
|
} from "electron";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { flags } from "./constants/flags";
|
|
||||||
import { globalEvents } from "./constants/globalEvents";
|
import { globalEvents } from "./constants/globalEvents";
|
||||||
import { mediaKeys } from "./constants/mediaKeys";
|
import { mediaKeys } from "./constants/mediaKeys";
|
||||||
|
import { settings } from "./constants/settings";
|
||||||
|
import { setDefaultFlags, setManagedFlagsFromSettings } from "./features/flags/flags";
|
||||||
|
import { Logger } from "./features/logger";
|
||||||
|
import { Songwhip } from "./features/songwhip/songwhip";
|
||||||
|
import { MediaInfo } from "./models/mediaInfo";
|
||||||
import { initRPC, rpc, unRPC } from "./scripts/discord";
|
import { initRPC, rpc, unRPC } from "./scripts/discord";
|
||||||
import { startExpress } from "./scripts/express";
|
import { startExpress } from "./scripts/express";
|
||||||
import { updateMediaInfo } from "./scripts/mediaInfo";
|
import { updateMediaInfo } from "./scripts/mediaInfo";
|
||||||
@ -20,14 +24,10 @@ import {
|
|||||||
closeSettingsWindow,
|
closeSettingsWindow,
|
||||||
createSettingsWindow,
|
createSettingsWindow,
|
||||||
hideSettingsWindow,
|
hideSettingsWindow,
|
||||||
showSettingsWindow,
|
|
||||||
settingsStore,
|
settingsStore,
|
||||||
|
showSettingsWindow,
|
||||||
} from "./scripts/settings";
|
} from "./scripts/settings";
|
||||||
import { settings } from "./constants/settings";
|
|
||||||
import { addTray, refreshTray } from "./scripts/tray";
|
import { addTray, refreshTray } from "./scripts/tray";
|
||||||
import { MediaInfo } from "./models/mediaInfo";
|
|
||||||
import { Songwhip } from "./features/songwhip/songwhip";
|
|
||||||
import { Logger } from "./features/logger";
|
|
||||||
const tidalUrl = "https://listen.tidal.com";
|
const tidalUrl = "https://listen.tidal.com";
|
||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
@ -36,26 +36,8 @@ let mainWindow: BrowserWindow;
|
|||||||
const icon = path.join(__dirname, "../assets/icon.png");
|
const icon = path.join(__dirname, "../assets/icon.png");
|
||||||
const PROTOCOL_PREFIX = "tidal";
|
const PROTOCOL_PREFIX = "tidal";
|
||||||
|
|
||||||
setFlags();
|
setDefaultFlags(app);
|
||||||
|
setManagedFlagsFromSettings(app);
|
||||||
function setFlags() {
|
|
||||||
const flagsFromSettings = settingsStore.get(settings.flags.root);
|
|
||||||
if (flagsFromSettings) {
|
|
||||||
for (const [key, value] of Object.entries(flags)) {
|
|
||||||
if (value) {
|
|
||||||
flags[key].forEach((flag) => {
|
|
||||||
console.log(`enabling command line switch ${flag.flag} with value ${flag.value}`);
|
|
||||||
app.commandLine.appendSwitch(flag.flag, flag.value);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fix Display Compositor issue.
|
|
||||||
*/
|
|
||||||
app.commandLine.appendSwitch("disable-seccomp-filter-sandbox");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the menuBarVisibility according to the store value
|
* Update the menuBarVisibility according to the store value
|
||||||
@ -90,8 +72,8 @@ function createWindow(options = { x: 0, y: 0, backgroundColor: "white" }) {
|
|||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
x: options.x,
|
x: options.x,
|
||||||
y: options.y,
|
y: options.y,
|
||||||
width: settingsStore && settingsStore.get(settings.windowBounds.width),
|
width: settingsStore?.get(settings.windowBounds.width),
|
||||||
height: settingsStore && settingsStore.get(settings.windowBounds.height),
|
height: settingsStore?.get(settings.windowBounds.height),
|
||||||
icon,
|
icon,
|
||||||
backgroundColor: options.backgroundColor,
|
backgroundColor: options.backgroundColor,
|
||||||
autoHideMenuBar: true,
|
autoHideMenuBar: true,
|
||||||
@ -224,7 +206,7 @@ ipcMain.on(globalEvents.error, (event) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle(globalEvents.whip, async (event, url) => {
|
ipcMain.handle(globalEvents.whip, async (event, url) => {
|
||||||
return await Songwhip.whip(url);
|
return Songwhip.whip(url);
|
||||||
});
|
});
|
||||||
|
|
||||||
Logger.watch(ipcMain);
|
Logger.watch(ipcMain);
|
||||||
|
Loading…
Reference in New Issue
Block a user