mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 17:41:40 -05:00
Switch state.ts to using lock with timeout
This commit is contained in:
parent
84d258c293
commit
fae68a0df6
1 changed files with 2 additions and 7 deletions
|
@ -58,9 +58,7 @@ const state = (new Proxy(overlay, {
|
|||
|
||||
/** Persist sets to storage "immediately" */
|
||||
set(target, property, value) {
|
||||
(async () => {
|
||||
await locks.acquire("state")
|
||||
|
||||
locks.withlock("state", async () => {
|
||||
logger.debug("State changed!", property, value)
|
||||
target[property] = value
|
||||
browser.storage.local.set({ state: target } as any)
|
||||
|
@ -74,10 +72,7 @@ const state = (new Proxy(overlay, {
|
|||
// I haven't had time to get my head around them
|
||||
browser.runtime.sendMessage({type: "state", command: "stateUpdate", args: [{state: target}]}),
|
||||
])
|
||||
|
||||
// Release named lock
|
||||
locks.release("state")
|
||||
})()
|
||||
})
|
||||
|
||||
return true
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue