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