diff --git a/app/dragManager.js b/app/dragManager.js index a878853a..b4c7fa11 100644 --- a/app/dragManager.js +++ b/app/dragManager.js @@ -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; diff --git a/app/fileManager.js b/app/fileManager.js index b9161502..fa059107 100644 --- a/app/fileManager.js +++ b/app/fileManager.js @@ -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) { diff --git a/app/pages/preview.js b/app/pages/preview.js index 5916780d..a6aa1bbf 100644 --- a/app/pages/preview.js +++ b/app/pages/preview.js @@ -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` + ${name}`; + + if (!pageAction) { + return title; + } const div = html`
- ${title} + ${title} ${' ' + size}
${state.translate('downloadMessage')}
${state.translate('downloadAltText')} + title="${state.translate('downloadAltText')}"/> ${pageAction}
${state.translate('sendYourFilesLink')} diff --git a/app/routes/download.js b/app/routes/download.js index c2073422..10cfe873 100644 --- a/app/routes/download.js +++ b/app/routes/download.js @@ -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') { diff --git a/app/routes/home.js b/app/routes/home.js index 3f101804..3d13e87f 100644 --- a/app/routes/home.js +++ b/app/routes/home.js @@ -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);