mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-01 19:49:54 +02:00
desktop: don't emit event when user changes theme
This commit is contained in:
committed by
Abdullah Atta
parent
736b2a17e9
commit
49272212bc
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user