From 441fe86186ec2651b307835d3d2e2b6414c73bcc Mon Sep 17 00:00:00 2001 From: Danny Coates Date: Mon, 7 Aug 2017 11:47:09 -0700 Subject: [PATCH] attach delete-file handler only after upload --- frontend/src/upload.js | 47 +++++++++++++++++++++--------------------- views/index.handlebars | 2 +- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/frontend/src/upload.js b/frontend/src/upload.js index 7b87fdc3..79ca4dd4 100644 --- a/frontend/src/upload.js +++ b/frontend/src/upload.js @@ -94,9 +94,6 @@ $(() => { $uploadWindow.removeClass('ondrag'); }); - //link back to homepage - $('.send-new').attr('href', window.location); - // on file upload by browse or drag & drop function onUpload(event) { event.preventDefault(); @@ -219,6 +216,30 @@ $(() => { uploadSpeed: speed }; + $('#delete-file').on('click', () => { + FileSender.delete( + fileData.fileId, + fileData.deleteToken + ).then(() => { + const ttl = + ONE_DAY_IN_MS - + (Date.now() - fileData.creationDate.getTime()); + metrics + .deletedUpload({ + size: fileData.size, + time: fileData.totalTime, + speed: fileData.uploadSpeed, + type: fileData.typeOfUpload, + location: 'success-screen', + ttl + }) + .then(() => { + storage.remove(fileData.fileId); + location.reload(); + }); + }); + }); + storage.addFile(info.fileId, fileData); $pageOne.attr('hidden', true); @@ -428,26 +449,6 @@ $(() => { }); }); - $('#delete-file').on('click', () => { - FileSender.delete(file.fileId, file.deleteToken).then(() => { - const ttl = - ONE_DAY_IN_MS - (Date.now() - file.creationDate.getTime()); - metrics - .deletedUpload({ - size: file.size, - time: file.totalTime, - speed: file.uploadSpeed, - type: file.typeOfUpload, - location: 'success-screen', - ttl - }) - .then(() => { - storage.remove(file.fileId); - location.reload(); - }); - }); - }); - // show popup $delIcon.on('click', () => { $popupText.addClass('show').focus(); diff --git a/views/index.handlebars b/views/index.handlebars index 33c1e1f7..0070b5dc 100644 --- a/views/index.handlebars +++ b/views/index.handlebars @@ -61,7 +61,7 @@ - +