[desktop] fix system theme applying

This commit is contained in:
Maxim Kadushkin 2022-08-09 18:26:01 +03:00
parent 9ee7a7054f
commit e9c2445afe
3 changed files with 11 additions and 4 deletions

View file

@ -291,9 +291,13 @@ define([
'modal:show': _onModalDialog.bind(this, 'open'),
'modal:close': _onModalDialog.bind(this, 'close'),
'uitheme:changed' : function (name) {
if (Common.localStorage.getBool('ui-theme-use-system', false)) {
native.execCommand("system:changed", JSON.stringify({'colorscheme':name}));
} else {
var theme = Common.UI.Themes.get(name);
if ( theme )
native.execCommand("uitheme:changed", JSON.stringify({name:name, type:theme.type}));
}
},
'hints:show': _onHintsShow.bind(this),
});

View file

@ -302,7 +302,9 @@ define([
$(window).on('storage', function (e) {
if ( e.key == 'ui-theme' || e.key == 'ui-theme-id' ) {
if ( !!e.originalEvent.newValue ) {
me.setTheme(e.originalEvent.newValue, true);
if (Common.localStorage.getBool('ui-theme-use-system', false)) {
me.setTheme('theme-system');
} else me.setTheme(e.originalEvent.newValue, true);
}
} else
if ( e.key == 'content-theme' ) {

View file

@ -65,6 +65,7 @@ if ( window.desktop ) {
if ( theme.id == 'theme-system' ) {
localStorage.setItem("ui-theme-use-system", "1");
localStorage.removeItem("ui-theme-id");
delete params.uitheme;
} else {
localStorage.setItem("ui-theme-id", theme.id);
}