feat: guards to prevent compiling this on web
This commit is contained in:
parent
91e093a21d
commit
5bc24a5d78
|
@ -60,13 +60,12 @@ export async function toggle(isEnabled: boolean) {
|
||||||
async function initThemes() {
|
async function initThemes() {
|
||||||
themesStyle ??= createStyle("vencord-themes");
|
themesStyle ??= createStyle("vencord-themes");
|
||||||
|
|
||||||
const { themeLinks, enabledThemes, userCssVars } = Settings;
|
const { themeLinks, enabledThemes } = Settings;
|
||||||
|
|
||||||
const links: string[] = [...themeLinks];
|
const links: string[] = [...themeLinks];
|
||||||
|
|
||||||
if (IS_WEB) {
|
if (IS_WEB) {
|
||||||
// UserCSS handled separately
|
for (const theme of enabledThemes) {
|
||||||
for (const theme of enabledThemes) if (!theme.endsWith(".user.css")) {
|
|
||||||
const themeData = await VencordNative.themes.getThemeData(theme);
|
const themeData = await VencordNative.themes.getThemeData(theme);
|
||||||
if (!themeData) continue;
|
if (!themeData) continue;
|
||||||
|
|
||||||
|
@ -79,24 +78,26 @@ async function initThemes() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const theme of enabledThemes) if (theme.endsWith(".user.css")) {
|
if (!IS_WEB || "armcord" in window) {
|
||||||
// UserCSS goes through a compile step first
|
for (const theme of enabledThemes) if (theme.endsWith(".user.css")) {
|
||||||
const css = await compileUsercss(theme);
|
// UserCSS goes through a compile step first
|
||||||
if (!css) {
|
const css = await compileUsercss(theme);
|
||||||
// let's not leave the user in the dark about this and point them to where they can find the error
|
if (!css) {
|
||||||
Toasts.show({
|
// let's not leave the user in the dark about this and point them to where they can find the error
|
||||||
message: `Failed to compile ${theme}, check the console for more info.`,
|
Toasts.show({
|
||||||
type: Toasts.Type.FAILURE,
|
message: `Failed to compile ${theme}, check the console for more info.`,
|
||||||
id: Toasts.genId(),
|
type: Toasts.Type.FAILURE,
|
||||||
options: {
|
id: Toasts.genId(),
|
||||||
position: Toasts.Position.BOTTOM
|
options: {
|
||||||
}
|
position: Toasts.Position.BOTTOM
|
||||||
});
|
}
|
||||||
continue;
|
});
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const blob = new Blob([css], { type: "text/css" });
|
const blob = new Blob([css], { type: "text/css" });
|
||||||
links.push(URL.createObjectURL(blob));
|
links.push(URL.createObjectURL(blob));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
themesStyle.textContent = links.map(link => `@import url("${link.trim()}");`).join("\n");
|
themesStyle.textContent = links.map(link => `@import url("${link.trim()}");`).join("\n");
|
||||||
|
|
Loading…
Reference in a new issue