Since we already are generating keys, lets use them.
This commit is contained in:
parent
642b1cd37d
commit
e20a822481
@ -797,20 +797,22 @@
|
||||
};
|
||||
timeout = {};
|
||||
setArea = function(area) {
|
||||
var data;
|
||||
var data, keys;
|
||||
data = items[area];
|
||||
if (!Object.keys(data).length || timeout[area] > Date.now()) {
|
||||
keys = Object.keys(data);
|
||||
if (!keys.length || timeout[area] > Date.now()) {
|
||||
return;
|
||||
}
|
||||
chrome.storage[area].set(data, function() {
|
||||
var key, val;
|
||||
var key, val, _i, _len;
|
||||
if (chrome.runtime.lastError) {
|
||||
c.error(chrome.runtime.lastError.message);
|
||||
for (key in data) {
|
||||
val = data[key];
|
||||
if (!(!(key in items[area]))) {
|
||||
for (_i = 0, _len = keys.length; _i < _len; _i++) {
|
||||
key = keys[_i];
|
||||
if (!(!items[area][key])) {
|
||||
continue;
|
||||
}
|
||||
val = data[key];
|
||||
if (area === 'sync' && chrome.storage.sync.QUOTA_BYTES_PER_ITEM < JSON.stringify(val).length + key.length) {
|
||||
c.error(chrome.runtime.lastError.message, key, val);
|
||||
continue;
|
||||
|
||||
@ -347,11 +347,13 @@ do ->
|
||||
timeout = {}
|
||||
setArea = (area) ->
|
||||
data = items[area]
|
||||
return if !Object.keys(data).length or timeout[area] > Date.now()
|
||||
keys = Object.keys data
|
||||
return if !keys.length or timeout[area] > Date.now()
|
||||
chrome.storage[area].set data, ->
|
||||
if chrome.runtime.lastError
|
||||
c.error chrome.runtime.lastError.message
|
||||
for key, val of data when key not of items[area]
|
||||
for key in keys when !items[area][key]
|
||||
val = data[key]
|
||||
if area is 'sync' and chrome.storage.sync.QUOTA_BYTES_PER_ITEM < JSON.stringify(val).length + key.length
|
||||
c.error chrome.runtime.lastError.message, key, val
|
||||
continue
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user