mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2025-08-23 21:15:00 +02:00
feat: Custom CSS now also applies to settings window
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { app, dialog, Notification } from "@electron/remote";
|
||||
import { clipboard, ipcRenderer } from "electron";
|
||||
import fs from "fs";
|
||||
import Player from "mpris-service";
|
||||
import { globalEvents } from "./constants/globalEvents";
|
||||
import { settings } from "./constants/settings";
|
||||
@@ -12,6 +11,7 @@ import {
|
||||
import { StoreData } from "./features/listenbrainz/models/storeData";
|
||||
import { Logger } from "./features/logger";
|
||||
import { Songwhip } from "./features/songwhip/songwhip";
|
||||
import { addCustomCss } from "./features/theming/theming";
|
||||
import { MediaStatus } from "./models/mediaStatus";
|
||||
import { Options } from "./models/options";
|
||||
import { downloadFile } from "./scripts/download";
|
||||
@@ -158,32 +158,6 @@ const elements = {
|
||||
},
|
||||
};
|
||||
|
||||
function addCustomCss() {
|
||||
window.addEventListener("DOMContentLoaded", () => {
|
||||
const selectedTheme = settingsStore.get<string, string>(settings.theme);
|
||||
if (selectedTheme !== "none") {
|
||||
const userThemePath = `${app.getPath("userData")}/themes/${selectedTheme}`;
|
||||
const resourcesThemePath = `${process.resourcesPath}/${selectedTheme}`;
|
||||
const themeFile = fs.existsSync(userThemePath) ? userThemePath : resourcesThemePath;
|
||||
fs.readFile(themeFile, "utf-8", (err, data) => {
|
||||
if (err) {
|
||||
Logger.alert("An error ocurred reading the theme file.", err, alert);
|
||||
return;
|
||||
}
|
||||
|
||||
const themeStyle = document.createElement("style");
|
||||
themeStyle.innerHTML = data;
|
||||
document.head.appendChild(themeStyle);
|
||||
});
|
||||
}
|
||||
|
||||
// read customCSS (it will override the theme)
|
||||
const style = document.createElement("style");
|
||||
style.innerHTML = settingsStore.get<string, string[]>(settings.customCSS).join("\n");
|
||||
document.head.appendChild(style);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the update frequency from the store
|
||||
* make sure it returns a number, if not use the default
|
||||
@@ -596,7 +570,8 @@ if (process.platform === "linux" && settingsStore.get(settings.mpris)) {
|
||||
console.log("player api not working");
|
||||
}
|
||||
}
|
||||
addCustomCss();
|
||||
|
||||
addCustomCss(app, Logger.bind(this));
|
||||
addHotKeys();
|
||||
addIPCEventListeners();
|
||||
addFullScreenListeners();
|
||||
|
Reference in New Issue
Block a user