Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

desktop: don't emit event when user changes theme

Abdullah Atta49272212bcfb
diff --git a/apps/web/desktop/config/theme.js b/apps/web/desktop/config/theme.js
index 8251d537d..12de6c881 100644
--- a/apps/web/desktop/config/theme.js
+++ b/apps/web/desktop/config/theme.js
@@ -25,7 +25,7 @@ function getTheme() {
}
function setTheme(theme) {
- nativeTheme.themeSource = theme;
+ changeTheme(theme);
if (globalThis.window)
globalThis.window.setBackgroundColor(getBackgroundColor(theme));
return JSONStorage.set("theme", theme);
@@ -35,4 +35,15 @@ function getBackgroundColor() {
return nativeTheme.shouldUseDarkColors ? "#0f0f0f" : "#ffffff";
}
-export { getTheme, setTheme, getBackgroundColor };
+
+function changeTheme(theme) {
+ const listeners = nativeTheme.rawListeners("updated");
+ nativeTheme.removeAllListeners("updated");
+
+ nativeTheme.themeSource = theme;
+
+ setTimeout(
+ () => listeners.forEach((a) => nativeTheme.addListener("updated", a)),
+ 1000
+ );
+}