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
|
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
|
||||||
|
|
||||||
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
|
||||||
), 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']
|
||||||
@setEnabled @enabled
|
|
||||||
else
|
else
|
||||||
log "Toggle state not yet saved"
|
log "Toggle state not yet saved"
|
||||||
|
@setEnabled @enabled
|
||||||
)
|
)
|
||||||
catch
|
|
||||||
log "Error retrieving toggle state"
|
|
||||||
|
|
||||||
postActive: ->
|
postActive: ->
|
||||||
@port?.postMessage
|
@port?.postMessage
|
||||||
|
@ -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()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue