mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-08 14:13:01 -04:00
Merge upstream/dev
This commit is contained in:
commit
9dabf4b201
15 changed files with 337 additions and 228 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue