From b9b2c4cbd7a7a2f662aa5128eb2bcf56aae99b0c Mon Sep 17 00:00:00 2001 From: tophf Date: Fri, 16 Feb 2018 12:43:22 +0300 Subject: [PATCH] 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 --- manage/updater-ui.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/manage/updater-ui.js b/manage/updater-ui.js index 8e95284c..dbfc1d1c 100644 --- a/manage/updater-ui.js +++ b/manage/updater-ui.js @@ -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;