Fix issues with trim history button

pull/1/head
yflory 5 years ago
parent 6f742fc295
commit 59d23ef5ff

@ -68,6 +68,9 @@
} }
} }
} }
button.cp-button-confirm-placeholder {
margin-bottom: 3px !important;
}
button:not(.pure-button):not(.md-button):not(.mdl-button) { button:not(.pure-button):not(.md-button):not(.mdl-button) {

@ -623,9 +623,9 @@ define([
var to; var to;
var done = function (res) { var done = function (res) {
cb(res); if (res) { cb(res); }
clearTimeout(to); clearTimeout(to);
$(content).remove(); $(content).detach();
$(originalBtn).show(); $(originalBtn).show();
}; };
@ -646,9 +646,12 @@ define([
$(div).css('width', p+'%'); $(div).css('width', p+'%');
to = setTimeout(todo, INTERVAL); 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);
});
}; };

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

@ -1258,27 +1258,24 @@ define([
return; return;
} }
$(currentSize).html(Messages._getKey('trimHistory_currentSize', [UIElements.prettySize(size)])); $(currentSize).html(Messages._getKey('trimHistory_currentSize', [UIElements.prettySize(size)]));
$button.click(function () { $button.prop('disabled', '');
UI.confirmButton(button, { UI.confirmButton(button, {
classes: 'btn-danger' classes: 'btn-danger'
}, function (yes) { }, function () {
if (!yes) { return; } $button.remove();
spinner.spin();
$button.remove(); APP.history.execCommand('TRIM_HISTORY', {
spinner.spin(); channels: channels
APP.history.execCommand('TRIM_HISTORY', { }, function (obj) {
channels: channels if (obj && obj.error) {
}, function (obj) { var error = h('div.alert.alert-danger', Messages.trimHistory_error);
if (obj && obj.error) { $(content).empty().append(error);
var error = h('div.alert.alert-danger', Messages.trimHistory_error); return;
$(content).empty().append(error); }
return; spinner.hide();
} redrawTrimHistory(cb, $div);
spinner.hide();
redrawTrimHistory(cb, $div);
});
}); });
}).prop('disabled', ''); });
}); });
$div.find('#cp-settings-trim-container').remove(); $div.find('#cp-settings-trim-container').remove();

Loading…
Cancel
Save