correctly finish check-all-updates before updating UI

now that we use messaging for the observer we can't use Promise for the final task;
fixes #341
This commit is contained in:
tophf 2018-02-16 12:43:22 +03:00
parent 654f63b894
commit b9b2c4cbd7

View File

@ -57,9 +57,9 @@ function checkUpdateAll() {
save: false,
observe: true,
ignoreDigest,
}).then(done);
});
function observer(info) {
function observer(info, port) {
if ('count' in info) {
total = info.count;
}
@ -78,9 +78,10 @@ function checkUpdateAll() {
const progress = $('#update-progress');
const maxWidth = progress.parentElement.clientWidth;
progress.style.width = Math.round(checked / total * maxWidth) + 'px';
}
function done() {
if (checked < total) return;
port.onMessage.removeListener(observer);
document.body.classList.remove('update-in-progress');
btnCheck.disabled = total === 0;
btnApply.disabled = false;