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:
parent
654f63b894
commit
b9b2c4cbd7
|
@ -57,9 +57,9 @@ function checkUpdateAll() {
|
||||||
save: false,
|
save: false,
|
||||||
observe: true,
|
observe: true,
|
||||||
ignoreDigest,
|
ignoreDigest,
|
||||||
}).then(done);
|
});
|
||||||
|
|
||||||
function observer(info) {
|
function observer(info, port) {
|
||||||
if ('count' in info) {
|
if ('count' in info) {
|
||||||
total = info.count;
|
total = info.count;
|
||||||
}
|
}
|
||||||
|
@ -78,9 +78,10 @@ function checkUpdateAll() {
|
||||||
const progress = $('#update-progress');
|
const progress = $('#update-progress');
|
||||||
const maxWidth = progress.parentElement.clientWidth;
|
const maxWidth = progress.parentElement.clientWidth;
|
||||||
progress.style.width = Math.round(checked / total * maxWidth) + 'px';
|
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');
|
document.body.classList.remove('update-in-progress');
|
||||||
btnCheck.disabled = total === 0;
|
btnCheck.disabled = total === 0;
|
||||||
btnApply.disabled = false;
|
btnApply.disabled = false;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user