Fix issues with trim history button

This commit is contained in:
yflory
2020-02-24 11:28:20 +01:00
parent 6f742fc295
commit 59d23ef5ff
4 changed files with 50 additions and 50 deletions

View File

@@ -623,9 +623,9 @@ define([
var to;
var done = function (res) {
cb(res);
if (res) { cb(res); }
clearTimeout(to);
$(content).remove();
$(content).detach();
$(originalBtn).show();
};
@@ -646,9 +646,12 @@ define([
$(div).css('width', p+'%');
to = setTimeout(todo, INTERVAL);
};
to = setTimeout(todo, INTERVAL);
$(originalBtn).hide().after(content);
$(originalBtn).addClass('cp-button-confirm-placeholder').click(function () {
i = 1;
to = setTimeout(todo, INTERVAL);
$(originalBtn).hide().after(content);
});
};

View File

@@ -825,32 +825,29 @@ define([
$d.append(size);
var $button = $(button);
$button.click(function () {
UI.confirmButton(button, {
classes: 'btn-danger'
}, function (yes) {
if (!yes) { return; }
$button.remove();
spinner.spin();
history.execCommand('TRIM_HISTORY', {
pad: true,
channels: trimChannels,
teamId: typeof(owned) === "number" && owned
}, function (obj) {
spinner.hide();
if (obj && obj.error) {
$(size).append(h('div.alert.alert-danger', Messages.trimHistory_error));
return;
}
$(size).remove();
var formatted = UIElements.prettySize(bytes - historyBytes);
$d.append(h('div.cp-app-prop', [
Messages.upload_size,
h('br'),
h('span.cp-app-prop-content', formatted)
]));
});
UI.confirmButton(button, {
classes: 'btn-danger'
}, function () {
$button.remove();
spinner.spin();
history.execCommand('TRIM_HISTORY', {
pad: true,
channels: trimChannels,
teamId: typeof(owned) === "number" && owned
}, function (obj) {
spinner.hide();
if (obj && obj.error) {
$(size).append(h('div.alert.alert-danger', Messages.trimHistory_error));
return;
}
$(size).remove();
var formatted = UIElements.prettySize(bytes - historyBytes);
$d.append(h('div.cp-app-prop', [
Messages.upload_size,
h('br'),
h('span.cp-app-prop-content', formatted)
]));
$d.append(h('div.alert.alert-success', Messages.trimHistory_success));
});
});