Skip to content

Commit

Permalink
[desktop] send 'quickaccess:changed' message to native
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkadushkin committed Apr 16, 2024
1 parent eae525e commit ea0e56e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 8 additions & 0 deletions apps/common/main/lib/controller/Desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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')

Expand Down Expand Up @@ -576,6 +583,7 @@ define([
}
},
'hints:show': _onHintsShow.bind(this),
'quickaccess:changed': _onChangeQuickAccess.bind(this),
});

webapp.addListeners({
Expand Down
9 changes: 6 additions & 3 deletions apps/common/main/lib/view/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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 ) {
Expand Down

0 comments on commit ea0e56e

Please sign in to comment.