Skip to content
Snippets Groups Projects
Commit 2cd69f6f authored by Cecylia Bocovich's avatar Cecylia Bocovich
Browse files

Save webextension toggle state

Save whether the snowflake extension is currently enabled in local
storage so that users do not need to opt-in again every time the browser
is restarted
parent e9358402
No related branches found
No related tags found
No related merge requests found
......@@ -59,6 +59,7 @@ class WebExtUI extends UI
constructor: ->
@initStats()
@initToggle()
chrome.runtime.onConnect.addListener @onConnect
initStats: ->
......@@ -69,6 +70,18 @@ class WebExtUI extends UI
@postActive()
), 60 * 60 * 1000
initToggle: ->
try
getting = chrome.storage.local.get("snowflake-enabled", (result) =>
@enabled = result['snowflake-enabled']
update()
chrome.browserAction.setIcon
path:
32: "icons/status-" + (if @enabled then "on" else "off") + ".png"
)
catch
log "Toggle state not yet saved"
postActive: ->
@port?.postMessage
active: @active
......@@ -90,6 +103,7 @@ class WebExtUI extends UI
path:
32: "icons/status-" + (if @enabled then "on" else "off") + ".png"
@postActive()
storing = chrome.storage.local.set({"snowflake-enabled":@enabled}, () -> log "Stored toggle state")
onDisconnect: (port) =>
@port = null
......
......@@ -13,5 +13,6 @@
},
"default_title": "Snowflake",
"default_popup": "popup.html"
}
},
"permissions": ["storage"]
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment