mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-08 06:03:03 -04:00
Merge remote-tracking branch 'upstream/dev' into dev
This commit is contained in:
commit
be9657269c
14 changed files with 98 additions and 45 deletions
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue