From 2292267e3995eb0f7ddcbac20aa37d08d3ef8efd Mon Sep 17 00:00:00 2001 From: Danny Coates Date: Thu, 1 Feb 2018 11:42:07 -0800 Subject: [PATCH] remove download cancel button while decrypting --- app/fileManager.js | 2 +- app/fileReceiver.js | 1 + app/pages/download.js | 35 +++++++++++++++++++---------------- app/routes/download.js | 2 +- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/app/fileManager.js b/app/fileManager.js index fa059107..cd353b62 100644 --- a/app/fileManager.js +++ b/app/fileManager.js @@ -53,7 +53,7 @@ export default function(state, emitter) { checkFiles(); }); - // emitter.on('navigate', checkFiles); + emitter.on('navigate', checkFiles); emitter.on('render', () => { lastRender = Date.now(); diff --git a/app/fileReceiver.js b/app/fileReceiver.js index 03347dcd..695d5938 100644 --- a/app/fileReceiver.js +++ b/app/fileReceiver.js @@ -64,6 +64,7 @@ export default class FileReceiver extends Nanobus { const ciphertext = await download.result; this.fileDownload = null; this.msg = 'decryptingFile'; + this.state = 'decrypting'; this.emit('decrypting'); const plaintext = await this.keychain.decryptFile(ciphertext); if (this.cancelled) { diff --git a/app/pages/download.js b/app/pages/download.js index eb6b8b37..4a415f17 100644 --- a/app/pages/download.js +++ b/app/pages/download.js @@ -4,30 +4,33 @@ const { bytes } = require('../utils'); module.exports = function(state, emit) { const transfer = state.transfer; + const cancelBtn = html` + `; + const div = html`
-
${state.translate( - 'downloadingPageProgress', - { +
+ ${state.translate('downloadingPageProgress', { filename: state.fileInfo.name, size: bytes(state.fileInfo.size) - } - )}
-
${state.translate( - 'downloadingPageMessage' - )}
+ })} +
+
+ ${state.translate('downloadingPageMessage')} +
${progress(transfer.progressRatio)}
-
${state.translate( - transfer.msg, - transfer.sizes - )}
- +
+ ${state.translate(transfer.msg, transfer.sizes)} +
+ ${transfer.state === 'downloading' ? cancelBtn : null}
diff --git a/app/routes/download.js b/app/routes/download.js index 10cfe873..63267d56 100644 --- a/app/routes/download.js +++ b/app/routes/download.js @@ -46,7 +46,7 @@ module.exports = function(state, emit) { let pageAction = null; //default state: we don't have file metadata if (state.transfer) { const s = state.transfer.state; - if (s === 'downloading' || s === 'complete') { + if (['downloading', 'decrypting', 'complete'].indexOf(s) > -1) { // Downloading is in progress return download(state, emit); }