Merge pull request #2073 from filips123/fix-infinite-reloading
Fix infinite reloading when system theme changes
This commit is contained in:
commit
5a746769d0
2 changed files with 25 additions and 11 deletions
|
@ -9,10 +9,10 @@ changeColorScheme = (theme) ->
|
||||||
zeroframe.cmd "userGetGlobalSettings", [], (user_settings) ->
|
zeroframe.cmd "userGetGlobalSettings", [], (user_settings) ->
|
||||||
if user_settings.theme != theme
|
if user_settings.theme != theme
|
||||||
user_settings.theme = theme
|
user_settings.theme = theme
|
||||||
zeroframe.cmd "userSetGlobalSettings", [user_settings]
|
zeroframe.cmd "userSetGlobalSettings", [user_settings], (status) ->
|
||||||
|
if status == "ok"
|
||||||
location.reload()
|
location.reload()
|
||||||
|
return
|
||||||
return
|
return
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -21,7 +21,12 @@ displayNotification = ({matches, media}) ->
|
||||||
if !matches
|
if !matches
|
||||||
return
|
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
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1981,7 +1981,6 @@ $.extend( $.easing,
|
||||||
|
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
|
||||||
|
|
||||||
/* ---- src/Ui/media/WrapperZeroFrame.coffee ---- */
|
/* ---- src/Ui/media/WrapperZeroFrame.coffee ---- */
|
||||||
|
|
||||||
|
|
||||||
|
@ -2037,7 +2036,8 @@ $.extend( $.easing,
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
(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)";
|
DARK = "(prefers-color-scheme: dark)";
|
||||||
|
|
||||||
|
@ -2051,8 +2051,11 @@ $.extend( $.easing,
|
||||||
zeroframe.cmd("userGetGlobalSettings", [], function(user_settings) {
|
zeroframe.cmd("userGetGlobalSettings", [], function(user_settings) {
|
||||||
if (user_settings.theme !== theme) {
|
if (user_settings.theme !== theme) {
|
||||||
user_settings.theme = theme;
|
user_settings.theme = theme;
|
||||||
zeroframe.cmd("userSetGlobalSettings", [user_settings]);
|
zeroframe.cmd("userSetGlobalSettings", [user_settings], function(status) {
|
||||||
location.reload();
|
if (status === "ok") {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -2063,7 +2066,13 @@ $.extend( $.easing,
|
||||||
if (!matches) {
|
if (!matches) {
|
||||||
return;
|
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() {
|
detectColorScheme = function() {
|
||||||
|
@ -2082,4 +2091,4 @@ $.extend( $.easing,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
|
Loading…
Reference in a new issue