mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Move toggle initiation init-webext.coffee
Prevents repeat calls to update() on startup
This commit is contained in:
parent
6210b5ea7f
commit
4494dbd3ca
2 changed files with 12 additions and 12 deletions
|
@ -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"
|
||||
@setEnabled @enabled
|
||||
)
|
||||
catch
|
||||
log "Error retrieving toggle state"
|
||||
|
||||
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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue