mirror of
https://github.com/HelloZeroNet/ZeroNet.git
synced 2023-12-14 04:33:03 +01:00
Fix infinite reloading when system theme changes
This commit is contained in:
parent
951e47469a
commit
87b4500467
2 changed files with 25 additions and 11 deletions
|
@ -9,10 +9,10 @@ changeColorScheme = (theme) ->
|
|||
zeroframe.cmd "userGetGlobalSettings", [], (user_settings) ->
|
||||
if user_settings.theme != theme
|
||||
user_settings.theme = theme
|
||||
zeroframe.cmd "userSetGlobalSettings", [user_settings]
|
||||
|
||||
location.reload()
|
||||
|
||||
zeroframe.cmd "userSetGlobalSettings", [user_settings], (status) ->
|
||||
if status == "ok"
|
||||
location.reload()
|
||||
return
|
||||
return
|
||||
return
|
||||
|
||||
|
@ -21,7 +21,12 @@ displayNotification = ({matches, media}) ->
|
|||
if !matches
|
||||
return
|
||||
|
||||
zeroframe.cmd "wrapperNotification", ["info", "Your system's theme has been changed.<br>Please reload site to use it."]
|
||||
zeroframe.cmd "siteInfo", [], (site_info) ->
|
||||
if "ADMIN" in site_info.settings.permissions
|
||||
zeroframe.cmd "wrapperNotification", ["info", "Your system's theme has been changed.<br>Please reload site to use it."]
|
||||
else
|
||||
zeroframe.cmd "wrapperNotification", ["info", "Your system's theme has been changed.<br>Please open ZeroHello to use it."]
|
||||
return
|
||||
return
|
||||
|
||||
|
||||
|
|
|
@ -1981,7 +1981,6 @@ $.extend( $.easing,
|
|||
|
||||
}).call(this);
|
||||
|
||||
|
||||
/* ---- src/Ui/media/WrapperZeroFrame.coffee ---- */
|
||||
|
||||
|
||||
|
@ -2037,7 +2036,8 @@ $.extend( $.easing,
|
|||
|
||||
|
||||
(function() {
|
||||
var DARK, LIGHT, changeColorScheme, detectColorScheme, displayNotification, mqDark, mqLight;
|
||||
var DARK, LIGHT, changeColorScheme, detectColorScheme, displayNotification, mqDark, mqLight,
|
||||
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
|
||||
DARK = "(prefers-color-scheme: dark)";
|
||||
|
||||
|
@ -2051,8 +2051,11 @@ $.extend( $.easing,
|
|||
zeroframe.cmd("userGetGlobalSettings", [], function(user_settings) {
|
||||
if (user_settings.theme !== theme) {
|
||||
user_settings.theme = theme;
|
||||
zeroframe.cmd("userSetGlobalSettings", [user_settings]);
|
||||
location.reload();
|
||||
zeroframe.cmd("userSetGlobalSettings", [user_settings], function(status) {
|
||||
if (status === "ok") {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -2063,7 +2066,13 @@ $.extend( $.easing,
|
|||
if (!matches) {
|
||||
return;
|
||||
}
|
||||
zeroframe.cmd("wrapperNotification", ["info", "Your system's theme has been changed.<br>Please reload site to use it."]);
|
||||
zeroframe.cmd("siteInfo", [], function(site_info) {
|
||||
if (indexOf.call(site_info.settings.permissions, "ADMIN") >= 0) {
|
||||
zeroframe.cmd("wrapperNotification", ["info", "Your system's theme has been changed.<br>Please reload site to use it."]);
|
||||
} else {
|
||||
zeroframe.cmd("wrapperNotification", ["info", "Your system's theme has been changed.<br>Please open ZeroHello to use it."]);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
detectColorScheme = function() {
|
||||
|
@ -2082,4 +2091,4 @@ $.extend( $.easing,
|
|||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
}).call(this);
|
||||
|
|
Loading…
Reference in a new issue