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);
|
||||
}
|
||||
|
||||
function flushQueue(stored) {
|
||||
if (!stored) {
|
||||
chrome.storage.local.get('updateLog', flushQueue);
|
||||
function flushQueue(lines) {
|
||||
if (!lines) {
|
||||
chromeLocal.getValue('updateLog', []).then(flushQueue);
|
||||
return;
|
||||
}
|
||||
const lines = stored.lines || [];
|
||||
const time = Date.now() - logLastWriteTime > 11e3 ?
|
||||
logQueue[0].time + ' ' :
|
||||
'';
|
||||
|
@ -242,7 +241,7 @@ global API_METHODS
|
|||
lines.push(time + (logQueue[0] && logQueue[0].text || ''));
|
||||
lines.push(...logQueue.slice(1).map(item => item.text));
|
||||
|
||||
chrome.storage.local.set({updateLog: lines});
|
||||
chromeLocal.setValue('updateLog', lines);
|
||||
logLastWriteTime = Date.now();
|
||||
logQueue = [];
|
||||
}
|
||||
|
|
|
@ -21,7 +21,18 @@ var [chromeLocal, chromeSync] = (() => {
|
|||
set: data => new Promise(resolve => storage.set(data, () => resolve(data))),
|
||||
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}),
|
||||
|
||||
getLZValue: key => wrapper.getLZValues([key]).then(data => data[key]),
|
||||
|
|
Loading…
Reference in New Issue
Block a user