fixup 3418ac9c: append to updateLog
This commit is contained in:
parent
3548a6caed
commit
d36fea27ad
|
@ -225,12 +225,11 @@ global API_METHODS
|
||||||
debounce(flushQueue, text && checkingAll ? 1000 : 0);
|
debounce(flushQueue, text && checkingAll ? 1000 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function flushQueue(stored) {
|
function flushQueue(lines) {
|
||||||
if (!stored) {
|
if (!lines) {
|
||||||
chrome.storage.local.get('updateLog', flushQueue);
|
chromeLocal.getValue('updateLog', []).then(flushQueue);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const lines = stored.lines || [];
|
|
||||||
const time = Date.now() - logLastWriteTime > 11e3 ?
|
const time = Date.now() - logLastWriteTime > 11e3 ?
|
||||||
logQueue[0].time + ' ' :
|
logQueue[0].time + ' ' :
|
||||||
'';
|
'';
|
||||||
|
@ -242,7 +241,7 @@ global API_METHODS
|
||||||
lines.push(time + (logQueue[0] && logQueue[0].text || ''));
|
lines.push(time + (logQueue[0] && logQueue[0].text || ''));
|
||||||
lines.push(...logQueue.slice(1).map(item => item.text));
|
lines.push(...logQueue.slice(1).map(item => item.text));
|
||||||
|
|
||||||
chrome.storage.local.set({updateLog: lines});
|
chromeLocal.setValue('updateLog', lines);
|
||||||
logLastWriteTime = Date.now();
|
logLastWriteTime = Date.now();
|
||||||
logQueue = [];
|
logQueue = [];
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,18 @@ var [chromeLocal, chromeSync] = (() => {
|
||||||
set: data => new Promise(resolve => storage.set(data, () => resolve(data))),
|
set: data => new Promise(resolve => storage.set(data, () => resolve(data))),
|
||||||
remove: data => new Promise(resolve => storage.remove(data, resolve)),
|
remove: data => new Promise(resolve => storage.remove(data, resolve)),
|
||||||
|
|
||||||
getValue: key => wrapper.get(key).then(data => data[key]),
|
/**
|
||||||
|
* @param {String} key
|
||||||
|
* @param {Any} [defaultValue]
|
||||||
|
* @returns {Promise<any>}
|
||||||
|
*/
|
||||||
|
getValue: (key, defaultValue) =>
|
||||||
|
wrapper.get(
|
||||||
|
defaultValue !== undefined ?
|
||||||
|
{[key]: defaultValue} :
|
||||||
|
key
|
||||||
|
).then(data => data[key]),
|
||||||
|
|
||||||
setValue: (key, value) => wrapper.set({[key]: value}),
|
setValue: (key, value) => wrapper.set({[key]: value}),
|
||||||
|
|
||||||
getLZValue: key => wrapper.getLZValues([key]).then(data => data[key]),
|
getLZValue: key => wrapper.getLZValues([key]).then(data => data[key]),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user