mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-29 00:14:23 -04:00
BetterFolders Fix For Themes
This commit is contained in:
parent
d938ad3a87
commit
2db53146c4
1 changed files with 21 additions and 12 deletions
|
@ -80,12 +80,10 @@ async function initThemes() {
|
||||||
themesStyle ??= createStyle("vencord-themes");
|
themesStyle ??= createStyle("vencord-themes");
|
||||||
|
|
||||||
const { enabledThemeLinks, enabledThemes } = Settings;
|
const { enabledThemeLinks, enabledThemes } = Settings;
|
||||||
|
|
||||||
const enabledlinks: string[] = [...enabledThemeLinks];
|
const enabledlinks: string[] = [...enabledThemeLinks];
|
||||||
// "darker" and "midnight" both count as dark
|
|
||||||
const activeTheme = ThemeStore.theme === "light" ? "light" : "dark";
|
const activeTheme = ThemeStore.theme === "light" ? "light" : "dark";
|
||||||
|
|
||||||
const links = enabledlinks
|
const rawLinks = enabledlinks
|
||||||
.map(rawLink => {
|
.map(rawLink => {
|
||||||
const match = /^@(light|dark) (.*)/.exec(rawLink);
|
const match = /^@(light|dark) (.*)/.exec(rawLink);
|
||||||
if (!match) return rawLink;
|
if (!match) return rawLink;
|
||||||
|
@ -93,19 +91,30 @@ async function initThemes() {
|
||||||
const [, mode, link] = match;
|
const [, mode, link] = match;
|
||||||
return mode === activeTheme ? link : null;
|
return mode === activeTheme ? link : null;
|
||||||
})
|
})
|
||||||
.filter(link => link !== null);
|
.filter((link): link is string => link !== null);
|
||||||
|
|
||||||
|
const links: string[] = [];
|
||||||
|
|
||||||
|
for (const url of rawLinks) {
|
||||||
|
try {
|
||||||
|
const res = await fetch(url);
|
||||||
|
const css = await res.text();
|
||||||
|
const patched = patchSidebar(css);
|
||||||
|
const blob = new Blob([patched], { type: "text/css" });
|
||||||
|
links.push(URL.createObjectURL(blob));
|
||||||
|
} catch (e) {
|
||||||
|
console.warn(`Failed to fetch theme from ${url}`, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (IS_WEB) {
|
|
||||||
for (const theme of enabledThemes) {
|
for (const theme of enabledThemes) {
|
||||||
const themeData = await VencordNative.themes.getThemeData(theme);
|
const themeData = await VencordNative.themes.getThemeData(theme);
|
||||||
if (!themeData) continue;
|
if (!themeData) continue;
|
||||||
const blob = new Blob([themeData], { type: "text/css" });
|
|
||||||
|
const patchedTheme = patchSidebar(themeData);
|
||||||
|
const blob = new Blob([patchedTheme], { type: "text/css" });
|
||||||
links.push(URL.createObjectURL(blob));
|
links.push(URL.createObjectURL(blob));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
const localThemes = enabledThemes.map(theme => `vencord:///themes/${theme}?v=${Date.now()}`);
|
|
||||||
links.push(...localThemes);
|
|
||||||
}
|
|
||||||
|
|
||||||
themesStyle.textContent = links.map(link => `@import url("${link.trim()}");`).join("\n");
|
themesStyle.textContent = links.map(link => `@import url("${link.trim()}");`).join("\n");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue