Implement wss preference url in html; Update to work with the tip of vnext branch; allow viewing the android ui from the webpack server (#918)

* Merge branch 'vnext' of https://github.com/mozilla/send into android-preferences

Fix conflicts

* Implement wss preference url in html; Update to work with the tip of vnext branch; allow viewing the android ui from the webpack server

* Use a try/catch in case localStorage isn't available, which it isn't in a ServiceWorker
This commit is contained in:
Donovan Preston 2018-09-06 18:56:04 -04:00 committed by GitHub
parent 690a705be9
commit 71ea4e74f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 97 additions and 6 deletions

View file

@ -1,6 +1,25 @@
import { arrayToB64, b64ToArray, delay } from './utils';
import { ECE_RECORD_SIZE } from './ece';
let fileProtocolWssUrl = null;
try {
fileProtocolWssUrl = localStorage.getItem('wssURL');
} catch (e) {
// NOOP
}
if (!fileProtocolWssUrl) {
fileProtocolWssUrl = 'wss://send2.dev.lcip.org/api/ws';
}
export function setFileProtocolWssUrl(url) {
localStorage && localStorage.setItem('wssURL', url);
fileProtocolWssUrl = url;
}
export function getFileProtocolWssUrl() {
return fileProtocolWssUrl;
}
function post(obj, bearerToken) {
const h = {
'Content-Type': 'application/json'
@ -147,7 +166,7 @@ async function upload(
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
const endpoint =
window.location.protocol === 'file:'
? 'wss://send2.dev.lcip.org/api/ws'
? fileProtocolWssUrl
: `${protocol}//${host}${port ? ':' : ''}${port}/api/ws`;
const ws = await asyncInitWebSocket(endpoint);