Skip to content
Snippets Groups Projects
Commit 685c3bd2 authored by Arlo Breault's avatar Arlo Breault
Browse files

Disable the webext if the bridge is unreachable

parent 19bc6d88
No related branches found
No related tags found
No related merge requests found
......@@ -31,14 +31,32 @@ class WebExtUI extends UI {
this.setEnabled(false);
return;
}
chrome.storage.local.get("snowflake-enabled", (result) => {
let enabled = this.enabled;
if (result['snowflake-enabled'] !== void 0) {
enabled = result['snowflake-enabled'];
} else {
log("Toggle state not yet saved");
}
this.setEnabled(enabled);
(new Promise((resolve, reject) => {
const ws = WS.makeWebsocket(config.relayAddr);
ws.onopen = () => {
resolve();
ws.close();
};
ws.onerror = () => {
this.missingFeature = 'popupBridgeUnreachable';
this.setEnabled(false);
reject('Could not connect to bridge.');
ws.close();
};
}))
.then(() => {
chrome.storage.local.get("snowflake-enabled", (result) => {
let enabled = this.enabled;
if (result['snowflake-enabled'] !== void 0) {
enabled = result['snowflake-enabled'];
} else {
log("Toggle state not yet saved");
}
this.setEnabled(enabled);
});
})
.catch((e) => {
log(e);
});
}
......
......@@ -23,6 +23,9 @@
"popupWebRTCOff": {
"message": "WebRTC feature is not detected."
},
"popupBridgeUnreachable": {
"message": "Could not connect to the bridge."
},
"popupDescOn": {
"message": "Number of users your Snowflake has helped circumvent censorship in the last 24 hours: $1"
},
......
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