From ea0e56ebadd4c4a9e05f3384fea9be72e69153be Mon Sep 17 00:00:00 2001 From: maxkadushkin Date: Tue, 16 Apr 2024 21:33:48 +0300 Subject: [PATCH] [desktop] send 'quickaccess:changed' message to native --- apps/common/main/lib/controller/Desktop.js | 8 ++++++++ apps/common/main/lib/view/Header.js | 9 ++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/common/main/lib/controller/Desktop.js b/apps/common/main/lib/controller/Desktop.js index c81a099bbd..83a58fa520 100644 --- a/apps/common/main/lib/controller/Desktop.js +++ b/apps/common/main/lib/controller/Desktop.js @@ -463,6 +463,9 @@ define([ if (!!header.btnRedo) titlebuttons['redo'] = {btn: header.btnRedo}; + if (!!header.btnQuickAccess) + titlebuttons['quickaccess'] = {btn: header.btnQuickAccess}; + for (var i in titlebuttons) { titlebuttons[i].btn.options.signals = ['disabled']; titlebuttons[i].btn.on('disabled', _onTitleButtonDisabled.bind(this, i)); @@ -519,6 +522,10 @@ define([ console.log('open recent'); } + const _onChangeQuickAccess = function (props) { + native.execCommand("quickaccess:changed", JSON.stringify(props)); + } + const _extend_menu_file = function (args) { console.log('extend menu file') @@ -576,6 +583,7 @@ define([ } }, 'hints:show': _onHintsShow.bind(this), + 'quickaccess:changed': _onChangeQuickAccess.bind(this), }); webapp.addListeners({ diff --git a/apps/common/main/lib/view/Header.js b/apps/common/main/lib/view/Header.js index a3284dd4fa..106a1f030f 100644 --- a/apps/common/main/lib/view/Header.js +++ b/apps/common/main/lib/view/Header.js @@ -311,7 +311,7 @@ define([ } } - function onChangeQuickAccess(props) { + function onChangeQuickAccess(caller, props) { if (props.save !== undefined) { this.btnSave[props.save ? 'show' : 'hide'](); Common.localStorage.setBool(this.appPrefix + 'quick-access-save', props.save); @@ -333,6 +333,9 @@ define([ Common.localStorage.setBool(this.appPrefix + 'quick-access-redo', props.redo); } Common.NotificationCenter.trigger('edit:complete'); + + if ( caller && caller == 'header' ) + Common.NotificationCenter.trigger('quickaccess:changed', props); } function onAppReady(mode) { @@ -530,9 +533,9 @@ define([ props.redo = item.checked; break; } - onChangeQuickAccess.call(me, props); + onChangeQuickAccess.call(me, 'header', props); }); - Common.NotificationCenter.on('quickaccess:changed', onChangeQuickAccess.bind(me)); + Common.NotificationCenter.on('quickaccess:changed', onChangeQuickAccess.bind(me, 'settings')); } if ( !appConfig.twoLevelHeader ) {