mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2024-11-22 05:23:09 +01:00
fixed errors with user theme files loading
This commit is contained in:
parent
4b81378423
commit
5ea3972053
@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [next]
|
||||
|
||||
- Fixed bug with theme files from user directory trying to load: "an error occurred reading the theme file"
|
||||
- Fixed: config flags not being set correctly
|
||||
- [DEV]:
|
||||
- Logger is now static and will automatically call either ipcRenderer or ipcMain
|
||||
|
@ -1,4 +1,5 @@
|
||||
import fs from "fs";
|
||||
import { Logger } from "../../features/logger";
|
||||
|
||||
const cssFilter = (file: string) => file.endsWith(".css");
|
||||
const sort = (a: string, b: string) => a.toLowerCase().localeCompare(b.toLowerCase());
|
||||
@ -36,7 +37,7 @@ export const getThemeListFromDirectory = (directory: string): string[] => {
|
||||
makeUserThemesDirectory(directory);
|
||||
return fs.readdirSync(directory).filter(cssFilter).sort(sort);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
Logger.log(`Failed to get files from ${directory}`, err);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
@ -49,6 +50,6 @@ export const makeUserThemesDirectory = (directory: string) => {
|
||||
try {
|
||||
fs.mkdirSync(directory, { recursive: true });
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
Logger.log(`Failed to make user theme directory: ${directory}`, err);
|
||||
}
|
||||
};
|
||||
|
@ -17,6 +17,7 @@ import { settingsStore } from "./scripts/settings";
|
||||
import { setTitle } from "./scripts/window-functions";
|
||||
import { StoreData } from "./features/listenbrainz/models/storeData";
|
||||
import { MediaStatus } from "./models/mediaStatus";
|
||||
import { Logger } from "./features/logger";
|
||||
|
||||
const notificationPath = `${app.getPath("userData")}/notification.jpg`;
|
||||
const appName = "Tidal Hifi";
|
||||
@ -157,12 +158,14 @@ const elements = {
|
||||
|
||||
function addCustomCss() {
|
||||
window.addEventListener("DOMContentLoaded", () => {
|
||||
const selectedTheme = settingsStore.get(settings.theme);
|
||||
const selectedTheme = settingsStore.get<string, string>(settings.theme);
|
||||
if (selectedTheme !== "none") {
|
||||
const themeFile = `${process.resourcesPath}/${selectedTheme}`;
|
||||
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) {
|
||||
alert("An error ocurred reading the theme file.");
|
||||
Logger.alert("An error ocurred reading the theme file.", err, alert);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user