From fae68a0df60839323fa60c881a2c183d27713444 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Sat, 29 Feb 2020 19:44:00 +0000 Subject: [PATCH] Switch state.ts to using lock with timeout --- src/state.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/state.ts b/src/state.ts index b9120366..0456ff69 100644 --- a/src/state.ts +++ b/src/state.ts @@ -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 },