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`