Only try to set state values in background script

I'm fairly surprised that this had any persistence at all
This commit is contained in:
Oliver Blanthorn 2020-06-23 15:00:00 +01:00
parent 090958809e
commit 70a2a3b72c
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3

View file

@ -90,12 +90,12 @@ export async function getAsync(property) {
}
// Keep instances of state.ts synchronised with each other
messaging.addListener("state", (message, sender, sendResponse) => {
!notBackground() && messaging.addListener("state", (message, sender, sendResponse) => {
if (message.command == "stateUpdate") {
const property = message.args.property
const value = message.args.value
logger.debug("State changed!", property, value)
overlay[property] = value
state[property] = value
} else if (message.command == "stateGet") {
sendResponse(state[message.args[0].prop])
} else throw "Unsupported message to state, type " + message.command