From 9740144e63c2b3e135ec0a5c52c8a6c800a593b0 Mon Sep 17 00:00:00 2001 From: tophf Date: Fri, 28 Apr 2017 19:44:03 +0300 Subject: [PATCH] Add an empty line before check-all in update log --- update.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/update.js b/update.js index f71ed5e0..cf2e0a97 100644 --- a/update.js +++ b/update.js @@ -21,10 +21,12 @@ var updater = { lastUpdateTime: parseInt(localStorage.lastUpdateTime) || Date.now(), checkAllStyles({observer = () => {}, save = true, ignoreDigest} = {}) { + updater.checkAllStyles.running = true; updater.resetInterval(); return getStyles({}).then(styles => { styles = styles.filter(style => style.updateUrl); observer(updater.COUNT, styles.length); + updater.log(''); updater.log(`${save ? 'Scheduled' : 'Manual'} update check for ${styles.length} styles`); return Promise.all( styles.map(style => @@ -32,6 +34,7 @@ var updater = { }).then(() => { observer(updater.DONE); updater.log(''); + updater.checkAllStyles.running = false; }); }, @@ -133,11 +136,17 @@ var updater = { let lastWriteTime = 0; return text => { queue.push({text, time: new Date().toLocaleString()}); - debounce(flushQueue, 1e3); + debounce(flushQueue, text && updater.checkAllStyles.running ? 1e3 : 0); }; function flushQueue() { chromeLocal.getValue('updateLog').then((lines = []) => { const time = Date.now() - lastWriteTime > 11e3 ? queue[0].time + ' ' : ''; + if (!queue[0].text) { + queue.shift(); + if (lines[lines.length - 1]) { + lines.push(''); + } + } lines.splice(0, lines.length - 1000); lines.push(time + queue[0].text); lines.push(...queue.slice(1).map(item => item.text));