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

Move toggle initiation init-webext.coffee

Prevents repeat calls to update() on startup
parent 6210b5ea
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,7 @@ init = () ->
snowflake = new Snowflake config, ui, broker
log '== snowflake proxy =='
update()
ui.initToggle()
update = () ->
if !ui.enabled
......
......@@ -59,7 +59,6 @@ class WebExtUI extends UI
constructor: ->
@initStats()
@initToggle()
chrome.runtime.onConnect.addListener @onConnect
initStats: ->
......@@ -71,16 +70,13 @@ class WebExtUI extends UI
), 60 * 60 * 1000
initToggle: ->
try
getting = chrome.storage.local.get("snowflake-enabled", (result) =>
if result['snowflake-enabled'] != undefined
@enabled = result['snowflake-enabled']
@setEnabled @enabled
else
log "Toggle state not yet saved"
)
catch
log "Error retrieving toggle state"
getting = chrome.storage.local.get("snowflake-enabled", (result) =>
if result['snowflake-enabled'] != undefined
@enabled = result['snowflake-enabled']
else
log "Toggle state not yet saved"
@setEnabled @enabled
)
postActive: ->
@port?.postMessage
......@@ -114,6 +110,10 @@ class WebExtUI extends UI
chrome.browserAction.setIcon
path:
32: "icons/status-running.png"
else
chrome.browserAction.setIcon
path:
32: "icons/status-on.png"
setEnabled: (enabled) ->
update()
......
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