[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [snowflake/master] Move toggle initiation init-webext.coffee
commit 4494dbd3ca95bddc306d0b677ef18ad81acb501c
Author: Cecylia Bocovich <cohosh@xxxxxxxxxxxxxx>
Date: Wed Jul 3 17:12:01 2019 -0400
Move toggle initiation init-webext.coffee
Prevents repeat calls to update() on startup
---
proxy/init-webext.coffee | 2 +-
proxy/ui.coffee | 22 +++++++++++-----------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/proxy/init-webext.coffee b/proxy/init-webext.coffee
index 7ff59ba..c2f47bf 100644
--- a/proxy/init-webext.coffee
+++ b/proxy/init-webext.coffee
@@ -24,7 +24,7 @@ init = () ->
snowflake = new Snowflake config, ui, broker
log '== snowflake proxy =='
- update()
+ ui.initToggle()
update = () ->
if !ui.enabled
diff --git a/proxy/ui.coffee b/proxy/ui.coffee
index e6896ec..2cc39dc 100644
--- a/proxy/ui.coffee
+++ b/proxy/ui.coffee
@@ -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()
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits