Fix cba reset on join. Change how the cba state is stored

This commit is contained in:
yflory
2020-04-21 12:04:24 +02:00
parent d8855ed5f7
commit 1d0feeb323
9 changed files with 126 additions and 119 deletions

View File

@@ -50,56 +50,6 @@ define([
// File and history size...
var owned = Modal.isOwned(Env, data);
var metadataMgr = common.getMetadataMgr();
var priv = metadataMgr.getPrivateData();
if (owned && priv.app === 'code') {
(function () {
var sframeChan = common.getSframeChannel();
var md = (opts.data && opts.data.metadata) || {};
var div = h('div');
var hint = h('div.cp-app-prop-hint', Messages.cba_hint);
var $div = $(div);
var setButton = function (state) {
var button = h('button.btn');
var $button = $(button);
$div.html('').append($button);
if (state) {
// Add "enable" button
$button.addClass('btn-secondary').text(Messages.cba_enable);
UI.confirmButton(button, {
classes: 'btn-primary'
}, function () {
$button.remove();
sframeChan.event("EV_SECURE_ACTION", {
cmd: 'UPDATE_METADATA',
key: 'enableColors',
value: true
});
common.setAttribute(['code', 'enableColors'], true);
setButton(false);
});
return;
}
// Add "disable" button
$button.addClass('btn-danger-alt').text(Messages.cba_disable);
UI.confirmButton(button, {
classes: 'btn-danger'
}, function () {
$button.remove();
sframeChan.event("EV_SECURE_ACTION", {
cmd: 'UPDATE_METADATA',
key: 'enableColors',
value: false
});
common.setAttribute(['code', 'enableColors'], false);
setButton(true);
});
};
setButton(!md.enableColors);
$d.append(h('div.cp-app-prop', [Messages.cba_properties, hint, div]));
})();
}
// check the size of this file, including additional channels
var bytes = 0;
var historyBytes;