Skip to content
This repository has been archived by the owner on May 22, 2021. It is now read-only.

Commit

Permalink
Merge pull request #468 from mozilla/i465
Browse files Browse the repository at this point in the history
attach delete-file handler only after upload
  • Loading branch information
dannycoates authored Aug 7, 2017
2 parents a70dcfc + 441fe86 commit aa72a4c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
47 changes: 24 additions & 23 deletions frontend/src/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion views/index.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<button id="copy-btn" data-l10n-id="copyUrlFormButton"></button>
</div>
<button id="delete-file" data-l10n-id="deleteFileButton"></button>
<a class="send-new" data-state="completed" data-l10n-id="sendAnotherFileLink"></a>
<a class="send-new" data-state="completed" data-l10n-id="sendAnotherFileLink" href="/"></a>
</div>
</div>

Expand Down

0 comments on commit aa72a4c

Please sign in to comment.