Merge pull request #2073 from filips123/fix-infinite-reloading

Fix infinite reloading when system theme changes
This commit is contained in:
ZeroNet 2019-07-06 23:25:35 +02:00 committed by GitHub
commit 5a746769d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 11 deletions

View File

@ -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

View File

@ -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);