From fde4d311e309768e6b3803e93cfb27fbad5e30e9 Mon Sep 17 00:00:00 2001 From: Danny Coates Date: Sun, 4 Feb 2018 18:30:33 -0800 Subject: [PATCH] added FileReceiver.reset --- app/fileManager.js | 3 ++- app/fileReceiver.js | 14 +++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/fileManager.js b/app/fileManager.js index 0845b1f2..895ca5c7 100644 --- a/app/fileManager.js +++ b/app/fileManager.js @@ -173,6 +173,7 @@ export default function(state, emitter) { await fadeOut('download-progress'); saveFile(f); state.storage.totalDownloads += 1; + state.transfer.reset(); metrics.completedDownload({ size, time, speed }); emitter.emit('pushState', '/completed'); } catch (err) { @@ -181,6 +182,7 @@ export default function(state, emitter) { return render(); } console.error(err); + state.transfer = null; const location = err.message === 'notfound' ? '/404' : '/error'; if (location === '/error') { state.raven.captureException(err); @@ -188,7 +190,6 @@ export default function(state, emitter) { } emitter.emit('pushState', location); } finally { - state.transfer = null; openLinksInNewTab(links, false); } }); diff --git a/app/fileReceiver.js b/app/fileReceiver.js index 695d5938..b3b5502e 100644 --- a/app/fileReceiver.js +++ b/app/fileReceiver.js @@ -11,11 +11,7 @@ export default class FileReceiver extends Nanobus { this.keychain.setPassword(fileInfo.password, fileInfo.url); } this.fileInfo = fileInfo; - this.fileDownload = null; - this.msg = 'fileSizeProgress'; - this.state = 'initialized'; - this.progress = [0, 1]; - this.cancelled = false; + this.reset(); } get progressRatio() { @@ -36,6 +32,14 @@ export default class FileReceiver extends Nanobus { } } + reset() { + this.fileDownload = null; + this.msg = 'fileSizeProgress'; + this.state = 'initialized'; + this.progress = [0, 1]; + this.cancelled = false; + } + async getMetadata() { const meta = await metadata(this.fileInfo.id, this.keychain); if (meta) {