attach delete-file handler only after upload

This commit is contained in:
Danny Coates 2017-08-07 11:47:09 -07:00
parent 097ff19c5f
commit 441fe86186
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
2 changed files with 25 additions and 24 deletions

View File

@ -94,9 +94,6 @@ $(() => {
$uploadWindow.removeClass('ondrag'); $uploadWindow.removeClass('ondrag');
}); });
//link back to homepage
$('.send-new').attr('href', window.location);
// on file upload by browse or drag & drop // on file upload by browse or drag & drop
function onUpload(event) { function onUpload(event) {
event.preventDefault(); event.preventDefault();
@ -219,6 +216,30 @@ $(() => {
uploadSpeed: speed 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); storage.addFile(info.fileId, fileData);
$pageOne.attr('hidden', true); $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 // show popup
$delIcon.on('click', () => { $delIcon.on('click', () => {
$popupText.addClass('show').focus(); $popupText.addClass('show').focus();

View File

@ -61,7 +61,7 @@
<button id="copy-btn" data-l10n-id="copyUrlFormButton"></button> <button id="copy-btn" data-l10n-id="copyUrlFormButton"></button>
</div> </div>
<button id="delete-file" data-l10n-id="deleteFileButton"></button> <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>
</div> </div>