fixed download preview page render issues and links

This commit is contained in:
Danny Coates 2018-01-31 15:47:34 -08:00
parent 41a0c6c73f
commit 232911f725
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
5 changed files with 21 additions and 14 deletions

View File

@ -6,7 +6,7 @@ export default function(state, emitter) {
}
});
document.body.addEventListener('drop', event => {
if (state.route === '/' && !state.transfer) {
if (state.route === '/' && !state.uploading) {
event.preventDefault();
document.querySelector('.upload-window').classList.remove('ondrag');
const target = event.dataTransfer;

View File

@ -92,6 +92,7 @@ export default function(state, emitter) {
sender.on('progress', updateProgress);
sender.on('encrypting', render);
state.transfer = sender;
state.uploading = true;
render();
const links = openLinksInNewTab();
@ -108,12 +109,10 @@ export default function(state, emitter) {
await delay(1000);
await fadeOut('upload-progress');
openLinksInNewTab(links, false);
state.transfer = null;
emitter.emit('pushState', `/share/${ownedFile.id}`);
} catch (err) {
console.error(err);
state.transfer = null;
if (err.message === '0') {
//cancelled. do nothing
metrics.cancelledUpload({ size, type });
@ -122,6 +121,9 @@ export default function(state, emitter) {
state.raven.captureException(err);
metrics.stoppedUpload({ size, type, err });
emitter.emit('pushState', '/error');
} finally {
state.uploading = false;
state.transfer = null;
}
});
@ -170,7 +172,6 @@ export default function(state, emitter) {
await fadeOut('download-progress');
saveFile(f);
state.storage.totalDownloads += 1;
state.transfer = null;
metrics.completedDownload({ size, time, speed });
emitter.emit('pushState', '/completed');
} catch (err) {

View File

@ -4,29 +4,35 @@ const { bytes } = require('../utils');
module.exports = function(state, pageAction) {
const fileInfo = state.fileInfo;
const size = fileInfo.size
? state.translate('downloadFileSize', { size: bytes(fileInfo.size) })
: '';
const title = fileInfo.name
const name = fileInfo.name
? state.translate('downloadFileName', { filename: fileInfo.name })
: state.translate('downloadFileTitle');
: '';
const title = html`
<span id="dl-file"
data-nonce="${fileInfo.nonce}"
data-requires-password="${fileInfo.requiresPassword}">${name}</span>`;
if (!pageAction) {
return title;
}
const div = html`
<div id="page-one">
<div id="download">
<div id="download-page-one">
<div class="title">
<span id="dl-file"
data-nonce="${fileInfo.nonce}"
data-requires-password="${fileInfo.requiresPassword}"
>${title}</span>
${title}
<span id="dl-filesize">${' ' + size}</span>
</div>
<div class="description">${state.translate('downloadMessage')}</div>
<img
src="${assets.get('illustration_download.svg')}"
id="download-img"
alt="${state.translate('downloadAltText')}"/>
title="${state.translate('downloadAltText')}"/>
${pageAction}
</div>
<a class="send-new" href="/">${state.translate('sendYourFilesLink')}</a>

View File

@ -43,7 +43,7 @@ module.exports = function(state, emit) {
}
}
let pageAction = ''; //default state: we don't have file metadata
let pageAction = null; //default state: we don't have file metadata
if (state.transfer) {
const s = state.transfer.state;
if (s === 'downloading' || s === 'complete') {

View File

@ -2,7 +2,7 @@ const welcome = require('../pages/welcome');
const upload = require('../pages/upload');
module.exports = function(state, emit) {
if (state.transfer) {
if (state.uploading) {
return upload(state, emit);
}
return welcome(state, emit);