Hook up the android kotlin code to the send js code (#860)

This commit is contained in:
Donovan Preston 2018-07-27 09:11:46 -04:00 committed by GitHub
parent 5c7b4ace9a
commit a80d007e0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 317 additions and 222 deletions

View file

@ -137,7 +137,12 @@ async function upload(
const host = window.location.hostname;
const port = window.location.port;
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
const ws = await asyncInitWebSocket(`${protocol}//${host}:${port}/api/ws`);
const endpoint =
window.location.protocol === 'file:'
? 'wss://send2.dev.lcip.org/api/ws'
: `${protocol}//${host}:${port}/api/ws`;
const ws = await asyncInitWebSocket(endpoint);
try {
const metadataHeader = arrayToB64(new Uint8Array(metadata));

View file

@ -108,8 +108,10 @@ export default function(state, emitter) {
if (cancelBtn) {
cancelBtn.hidden = 'hidden';
}
await delay(1000);
await fadeOut('.page');
if (document.querySelector('.page')) {
await delay(1000);
await fadeOut('.page');
}
emitter.emit('pushState', `/share/${ownedFile.id}`);
} catch (err) {
if (err.message === '0') {
@ -180,8 +182,10 @@ export default function(state, emitter) {
await dl;
const time = Date.now() - start;
const speed = size / (time / 1000);
await delay(1000);
await fadeOut('.page');
if (document.querySelector('.page')) {
await delay(1000);
await fadeOut('.page');
}
state.storage.totalDownloads += 1;
state.transfer.reset();
metrics.completedDownload({ size, time, speed });