Merge branch 'v3'
Conflicts: LICENSE builds/appchan-x.user.js builds/crx/script.js
This commit is contained in:
commit
c019634450
@ -3129,39 +3129,24 @@
|
||||
};
|
||||
|
||||
$.set = (function() {
|
||||
var items, setAll, setArea, timeout;
|
||||
items = {
|
||||
sync: {},
|
||||
local: {}
|
||||
};
|
||||
timeout = {};
|
||||
setArea = function(area) {
|
||||
if (timeout[area]) {
|
||||
return;
|
||||
}
|
||||
return chrome.storage[area].set(items[area], function() {
|
||||
if (chrome.runtime.lastError) {
|
||||
c.error(chrome.runtime.lastError.message);
|
||||
timeout[area] = setTimeout(setArea, $.MINUTE, area);
|
||||
return;
|
||||
}
|
||||
items[area] = {};
|
||||
return delete timeout[area];
|
||||
});
|
||||
};
|
||||
setAll = $.debounce($.SECOND, function() {
|
||||
var items, localItems, set;
|
||||
items = {};
|
||||
localItems = {};
|
||||
set = $.debounce($.SECOND, function() {
|
||||
var err, key, _i, _len, _ref;
|
||||
_ref = $.localKeys;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
key = _ref[_i];
|
||||
if (key in items.sync) {
|
||||
items.local[key] = items.sync[key];
|
||||
delete items.sync[key];
|
||||
if (key in items) {
|
||||
(localItems || (localItems = {}))[key] = items[key];
|
||||
delete items[key];
|
||||
}
|
||||
}
|
||||
try {
|
||||
setArea('local');
|
||||
return setArea('sync');
|
||||
chrome.storage.local.set(localItems);
|
||||
chrome.storage.sync.set(items);
|
||||
items = {};
|
||||
return localItems = {};
|
||||
} catch (_error) {
|
||||
err = _error;
|
||||
return c.error(err.stack);
|
||||
@ -3169,11 +3154,11 @@
|
||||
});
|
||||
return function(key, val) {
|
||||
if (typeof key === 'string') {
|
||||
items.sync[key] = val;
|
||||
items[key] = val;
|
||||
} else {
|
||||
$.extend(items.sync, key);
|
||||
$.extend(items, key);
|
||||
}
|
||||
return setAll();
|
||||
return set();
|
||||
};
|
||||
})();
|
||||
|
||||
|
||||
@ -329,38 +329,28 @@ $.get = (key, val, cb) ->
|
||||
chrome.storage.sync.get syncItems, done
|
||||
|
||||
$.set = do ->
|
||||
items =
|
||||
sync: {}
|
||||
local: {}
|
||||
timeout = {}
|
||||
items = {}
|
||||
localItems = {}
|
||||
|
||||
setArea = (area) ->
|
||||
return if timeout[area]
|
||||
chrome.storage[area].set items[area], ->
|
||||
if chrome.runtime.lastError
|
||||
c.error chrome.runtime.lastError.message
|
||||
timeout[area] = setTimeout setArea, $.MINUTE, area
|
||||
return
|
||||
items[area] = {}
|
||||
delete timeout[area]
|
||||
|
||||
setAll = $.debounce $.SECOND, ->
|
||||
set = $.debounce $.SECOND, ->
|
||||
for key in $.localKeys
|
||||
if key of items.sync
|
||||
items.local[key] = items.sync[key]
|
||||
delete items.sync[key]
|
||||
if key of items
|
||||
(localItems or= {})[key] = items[key]
|
||||
delete items[key]
|
||||
try
|
||||
setArea 'local'
|
||||
setArea 'sync'
|
||||
chrome.storage.local.set localItems
|
||||
chrome.storage.sync.set items
|
||||
items = {}
|
||||
localItems = {}
|
||||
catch err
|
||||
c.error err.stack
|
||||
|
||||
(key, val) ->
|
||||
if typeof key is 'string'
|
||||
items.sync[key] = val
|
||||
items[key] = val
|
||||
else
|
||||
$.extend items.sync, key
|
||||
setAll()
|
||||
$.extend items, key
|
||||
set()
|
||||
|
||||
<% } else { %>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user