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