fixed download preview page render issues and links
This commit is contained in:
parent
41a0c6c73f
commit
232911f725
|
@ -6,7 +6,7 @@ export default function(state, emitter) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
document.body.addEventListener('drop', event => {
|
document.body.addEventListener('drop', event => {
|
||||||
if (state.route === '/' && !state.transfer) {
|
if (state.route === '/' && !state.uploading) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
document.querySelector('.upload-window').classList.remove('ondrag');
|
document.querySelector('.upload-window').classList.remove('ondrag');
|
||||||
const target = event.dataTransfer;
|
const target = event.dataTransfer;
|
||||||
|
|
|
@ -92,6 +92,7 @@ export default function(state, emitter) {
|
||||||
sender.on('progress', updateProgress);
|
sender.on('progress', updateProgress);
|
||||||
sender.on('encrypting', render);
|
sender.on('encrypting', render);
|
||||||
state.transfer = sender;
|
state.transfer = sender;
|
||||||
|
state.uploading = true;
|
||||||
render();
|
render();
|
||||||
|
|
||||||
const links = openLinksInNewTab();
|
const links = openLinksInNewTab();
|
||||||
|
@ -108,12 +109,10 @@ export default function(state, emitter) {
|
||||||
await delay(1000);
|
await delay(1000);
|
||||||
await fadeOut('upload-progress');
|
await fadeOut('upload-progress');
|
||||||
openLinksInNewTab(links, false);
|
openLinksInNewTab(links, false);
|
||||||
state.transfer = null;
|
|
||||||
|
|
||||||
emitter.emit('pushState', `/share/${ownedFile.id}`);
|
emitter.emit('pushState', `/share/${ownedFile.id}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
state.transfer = null;
|
|
||||||
if (err.message === '0') {
|
if (err.message === '0') {
|
||||||
//cancelled. do nothing
|
//cancelled. do nothing
|
||||||
metrics.cancelledUpload({ size, type });
|
metrics.cancelledUpload({ size, type });
|
||||||
|
@ -122,6 +121,9 @@ export default function(state, emitter) {
|
||||||
state.raven.captureException(err);
|
state.raven.captureException(err);
|
||||||
metrics.stoppedUpload({ size, type, err });
|
metrics.stoppedUpload({ size, type, err });
|
||||||
emitter.emit('pushState', '/error');
|
emitter.emit('pushState', '/error');
|
||||||
|
} finally {
|
||||||
|
state.uploading = false;
|
||||||
|
state.transfer = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -170,7 +172,6 @@ export default function(state, emitter) {
|
||||||
await fadeOut('download-progress');
|
await fadeOut('download-progress');
|
||||||
saveFile(f);
|
saveFile(f);
|
||||||
state.storage.totalDownloads += 1;
|
state.storage.totalDownloads += 1;
|
||||||
state.transfer = null;
|
|
||||||
metrics.completedDownload({ size, time, speed });
|
metrics.completedDownload({ size, time, speed });
|
||||||
emitter.emit('pushState', '/completed');
|
emitter.emit('pushState', '/completed');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -4,29 +4,35 @@ const { bytes } = require('../utils');
|
||||||
|
|
||||||
module.exports = function(state, pageAction) {
|
module.exports = function(state, pageAction) {
|
||||||
const fileInfo = state.fileInfo;
|
const fileInfo = state.fileInfo;
|
||||||
|
|
||||||
const size = fileInfo.size
|
const size = fileInfo.size
|
||||||
? state.translate('downloadFileSize', { size: bytes(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('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`
|
const div = html`
|
||||||
<div id="page-one">
|
<div id="page-one">
|
||||||
<div id="download">
|
<div id="download">
|
||||||
<div id="download-page-one">
|
<div id="download-page-one">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<span id="dl-file"
|
${title}
|
||||||
data-nonce="${fileInfo.nonce}"
|
|
||||||
data-requires-password="${fileInfo.requiresPassword}"
|
|
||||||
>${title}</span>
|
|
||||||
<span id="dl-filesize">${' ' + size}</span>
|
<span id="dl-filesize">${' ' + size}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="description">${state.translate('downloadMessage')}</div>
|
<div class="description">${state.translate('downloadMessage')}</div>
|
||||||
<img
|
<img
|
||||||
src="${assets.get('illustration_download.svg')}"
|
src="${assets.get('illustration_download.svg')}"
|
||||||
id="download-img"
|
id="download-img"
|
||||||
alt="${state.translate('downloadAltText')}"/>
|
title="${state.translate('downloadAltText')}"/>
|
||||||
${pageAction}
|
${pageAction}
|
||||||
</div>
|
</div>
|
||||||
<a class="send-new" href="/">${state.translate('sendYourFilesLink')}</a>
|
<a class="send-new" href="/">${state.translate('sendYourFilesLink')}</a>
|
||||||
|
|
|
@ -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) {
|
if (state.transfer) {
|
||||||
const s = state.transfer.state;
|
const s = state.transfer.state;
|
||||||
if (s === 'downloading' || s === 'complete') {
|
if (s === 'downloading' || s === 'complete') {
|
||||||
|
|
|
@ -2,7 +2,7 @@ const welcome = require('../pages/welcome');
|
||||||
const upload = require('../pages/upload');
|
const upload = require('../pages/upload');
|
||||||
|
|
||||||
module.exports = function(state, emit) {
|
module.exports = function(state, emit) {
|
||||||
if (state.transfer) {
|
if (state.uploading) {
|
||||||
return upload(state, emit);
|
return upload(state, emit);
|
||||||
}
|
}
|
||||||
return welcome(state, emit);
|
return welcome(state, emit);
|
||||||
|
|
Loading…
Reference in New Issue