Merge upstream/dev

This commit is contained in:
thororen1234 2024-09-02 20:57:56 -04:00
commit 9dabf4b201
15 changed files with 337 additions and 228 deletions

View file

@ -17,6 +17,7 @@
*/
import { Settings, SettingsStore } from "@api/Settings";
import { ThemeStore } from "@webpack/common";
let style: HTMLStyleElement;
@ -59,7 +60,19 @@ async function initThemes() {
const { enabledThemeLinks, enabledThemes } = Settings;
const links: string[] = [...enabledThemeLinks];
const enabledlinks: string[] = [...enabledThemeLinks];
// "darker" and "midnight" both count as dark
const activeTheme = ThemeStore.theme === "light" ? "light" : "dark";
const links = enabledlinks
.map(rawLink => {
const match = /^@(light|dark) (.*)/.exec(rawLink);
if (!match) return rawLink;
const [, mode, link] = match;
return mode === activeTheme ? link : null;
})
.filter(link => link !== null);
if (IS_WEB) {
for (const theme of enabledThemes) {
@ -85,6 +98,7 @@ document.addEventListener("DOMContentLoaded", () => {
SettingsStore.addChangeListener("enabledThemeLinks", initThemes);
SettingsStore.addChangeListener("enabledThemes", initThemes);
ThemeStore.addChangeListener(initThemes);
if (!IS_WEB)
VencordNative.quickCss.addThemeChangeListener(initThemes);