Attemps to fix possible race condition in setArea(). #1342
This commit is contained in:
parent
6e450030f1
commit
c49579efcd
@ -271,13 +271,16 @@ $.set = do ->
|
|||||||
timeout = {}
|
timeout = {}
|
||||||
|
|
||||||
setArea = (area) ->
|
setArea = (area) ->
|
||||||
return if !Object.keys(items[area]).length or timeout[area]
|
data = items[area]
|
||||||
chrome.storage[area].set items[area], ->
|
return if !Object.keys(data).length or timeout[area]
|
||||||
|
items[area] = {}
|
||||||
|
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]
|
||||||
|
items[area][key] = val
|
||||||
timeout[area] = setTimeout setArea, $.MINUTE, area
|
timeout[area] = setTimeout setArea, $.MINUTE, area
|
||||||
return
|
return
|
||||||
items[area] = {}
|
|
||||||
delete timeout[area]
|
delete timeout[area]
|
||||||
|
|
||||||
setAll = $.debounce $.SECOND, ->
|
setAll = $.debounce $.SECOND, ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user