Add an empty line before check-all in update log

This commit is contained in:
tophf 2017-04-28 19:44:03 +03:00
parent 33fa5693ed
commit 9740144e63

View File

@ -21,10 +21,12 @@ var updater = {
lastUpdateTime: parseInt(localStorage.lastUpdateTime) || Date.now(), lastUpdateTime: parseInt(localStorage.lastUpdateTime) || Date.now(),
checkAllStyles({observer = () => {}, save = true, ignoreDigest} = {}) { checkAllStyles({observer = () => {}, save = true, ignoreDigest} = {}) {
updater.checkAllStyles.running = true;
updater.resetInterval(); updater.resetInterval();
return getStyles({}).then(styles => { return getStyles({}).then(styles => {
styles = styles.filter(style => style.updateUrl); styles = styles.filter(style => style.updateUrl);
observer(updater.COUNT, styles.length); observer(updater.COUNT, styles.length);
updater.log('');
updater.log(`${save ? 'Scheduled' : 'Manual'} update check for ${styles.length} styles`); updater.log(`${save ? 'Scheduled' : 'Manual'} update check for ${styles.length} styles`);
return Promise.all( return Promise.all(
styles.map(style => styles.map(style =>
@ -32,6 +34,7 @@ var updater = {
}).then(() => { }).then(() => {
observer(updater.DONE); observer(updater.DONE);
updater.log(''); updater.log('');
updater.checkAllStyles.running = false;
}); });
}, },
@ -133,11 +136,17 @@ var updater = {
let lastWriteTime = 0; let lastWriteTime = 0;
return text => { return text => {
queue.push({text, time: new Date().toLocaleString()}); queue.push({text, time: new Date().toLocaleString()});
debounce(flushQueue, 1e3); debounce(flushQueue, text && updater.checkAllStyles.running ? 1e3 : 0);
}; };
function flushQueue() { function flushQueue() {
chromeLocal.getValue('updateLog').then((lines = []) => { chromeLocal.getValue('updateLog').then((lines = []) => {
const time = Date.now() - lastWriteTime > 11e3 ? queue[0].time + ' ' : ''; 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.splice(0, lines.length - 1000);
lines.push(time + queue[0].text); lines.push(time + queue[0].text);
lines.push(...queue.slice(1).map(item => item.text)); lines.push(...queue.slice(1).map(item => item.text));