History trimming in settings

pull/1/head
yflory 5 years ago
parent b28f262c86
commit 53f19920f0

@ -1199,7 +1199,8 @@ define([
}; };
makeBlock('trim-history', function (cb) { makeBlock('trim-history', function (cb) {
// XXX settings_trimHistoryTitle, settings_trimHistoryHint, settings_trimHistoryButton if (!common.isLoggedIn()) { return; }
// XXX settings_trimHistoryTitle, settings_trimHistoryHint, settings_trimHistoryButton, settings_trimHistoryError
// XXX trimHistory_confirm // XXX trimHistory_confirm
var spinner = UI.makeSpinner(); var spinner = UI.makeSpinner();
@ -1214,17 +1215,42 @@ define([
spinner.spinner spinner.spinner
]); ]);
Messages.trimHistory_currentSize = 'Abcd: <b>{0}</b>'; // XXX Messages.trimHistory_currentSize = 'Size XXX: <b>{0}</b>'; // XXX
var $button = $(button);
var size; var size;
nThen(function (waitFor) { nThen(function (waitFor) {
size = UIElements.prettySize(1024*12); // XXX get size APP.history.execCommand('GET_HISTORY_SIZE', {
account: true,
channels: []
}, waitFor(function (obj) {
if (obj && obj.error) {
waitFor.abort();
var error = h('div.alert.alert-danger', Messages.settings_trimHistoryError || 'error'); // XXX
$(content).empty().append(error);
return;
}
size = UIElements.prettySize(Number(obj.size));
}));
}).nThen(function () { }).nThen(function () {
$(currentSize).html(Messages._getKey('trimHistory_currentSize', [size])); $(currentSize).html(Messages._getKey('trimHistory_currentSize', [size]));
$(button).click(function () { $button.click(function () {
UI.confirm(Messages.trimHistory_confirm, function (yes) { UI.confirm(Messages.trimHistory_confirm, function (yes) {
if (!yes) { return; } if (!yes) { return; }
$button.remove();
spinner.spin(); spinner.spin();
APP.history.execCommand('TRIM_HISTORY', {
account: true,
channels: []
}, function (obj) {
if (obj && obj.error) {
// XXX what are the possible errors?
return;
}
spinner.hide();
$(content).append(h('div.alert.alert-success', Messages.settings_trimHistorySuccess || 'ok')); // XXX
});
}); });
}).prop('disabled', ''); }).prop('disabled', '');
}); });
@ -1716,6 +1742,7 @@ define([
}; };
APP.toolbar = Toolbar.create(configTb); APP.toolbar = Toolbar.create(configTb);
APP.toolbar.$rightside.hide(); APP.toolbar.$rightside.hide();
APP.history = common.makeUniversal('history');
// Content // Content
var $rightside = APP.$rightside; var $rightside = APP.$rightside;
@ -1734,6 +1761,7 @@ define([
categories[cat].forEach(addItem); categories[cat].forEach(addItem);
} }
// TODO RPC // TODO RPC
//obj.proxy.on('change', [], refresh); //obj.proxy.on('change', [], refresh);
//obj.proxy.on('remove', [], refresh); //obj.proxy.on('remove', [], refresh);

Loading…
Cancel
Save