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:
parent
690a705be9
commit
71ea4e74f6
7 changed files with 97 additions and 6 deletions
21
app/api.js
21
app/api.js
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue