Merge remote-tracking branch 'upstream/dev' into dev
Some checks are pending
Release / Build Equicord (push) Waiting to run
Test / Test (push) Waiting to run

This commit is contained in:
thororen1234 2025-05-14 19:40:37 -04:00
commit be9657269c
No known key found for this signature in database
14 changed files with 98 additions and 45 deletions

View file

@ -17,7 +17,7 @@
*/
import { Settings, SettingsStore } from "@api/Settings";
import { findByCodeLazy } from "@webpack";
import { ThemeStore } from "@webpack/common";
let style: HTMLStyleElement;
let themesStyle: HTMLStyleElement;
@ -61,8 +61,10 @@ async function initThemes() {
const enabledlinks: string[] = [...enabledThemeLinks];
// "darker" and "midnight" both count as dark
const ThemeStore = findByCodeLazy("ThemeStore");
const activeTheme = ThemeStore.theme === "light" ? "light" : "dark";
// This function is first called on DOMContentLoaded, so ThemeStore may not have been loaded yet
const activeTheme = ThemeStore == null
? undefined
: ThemeStore.theme === "light" ? "light" : "dark";
const links = enabledlinks
.map(rawLink => {
@ -91,7 +93,6 @@ async function initThemes() {
document.addEventListener("DOMContentLoaded", () => {
initSystemValues();
initThemes();
toggle(Settings.useQuickCss);
SettingsStore.addChangeListener("useQuickCss", toggle);
@ -99,6 +100,21 @@ document.addEventListener("DOMContentLoaded", () => {
SettingsStore.addChangeListener("enabledThemeLinks", initThemes);
SettingsStore.addChangeListener("enabledThemes", initThemes);
if (!IS_WEB)
if (!IS_WEB) {
VencordNative.quickCss.addThemeChangeListener(initThemes);
}
initThemes();
});
export function initQuickCssThemeStore() {
initThemes();
let currentTheme = ThemeStore.theme;
ThemeStore.addChangeListener(() => {
if (currentTheme === ThemeStore.theme) return;
currentTheme = ThemeStore.theme;
initThemes();
});
}