small fixes and style changes

This commit is contained in:
schlagmichdoch 2023-01-17 14:00:01 +01:00
parent c7ee067ef2
commit 474eb9290f
4 changed files with 18 additions and 8 deletions

View file

@ -361,7 +361,7 @@ class Peer {
this._onDownloadProgress(message.progress);
break;
case 'files-transfer-response':
this._onFileTransferResponded(message);
this._onFileTransferRequestResponded(message);
break;
case 'file-transfer-complete':
this._onFileTransferCompleted();
@ -456,7 +456,7 @@ class Peer {
Events.fire('deactivate-paste-mode');
}
_onFileTransferResponded(message) {
_onFileTransferRequestResponded(message) {
if (!message.accepted) {
Events.fire('set-progress', {peerId: this._peerId, progress: 1, status: 'wait'});

View file

@ -438,9 +438,10 @@ class ReceiveDialog extends Dialog {
class ReceiveFileDialog extends ReceiveDialog {
constructor() {
super('receiveDialog', false);
super('receiveFileDialog', false);
this.$shareOrDownloadBtn = this.$el.querySelector('#shareOrDownload');
this.$receiveTitleNode = this.$el.querySelector('#receiveTitle')
Events.on('files-received', e => this._onFilesReceived(e.detail.sender, e.detail.files));
this._filesQueue = [];
@ -503,13 +504,16 @@ class ReceiveFileDialog extends ReceiveDialog {
let description;
let size;
let filename;
let title;
if (files.length === 1) {
title = 'PairDrop - File Received'
description = files[0].name;
size = this._formatFileSize(files[0].size);
filename = files[0].name;
url = URL.createObjectURL(files[0])
} else {
title = `PairDrop - ${files.length} Files Received`
let completeSize = 0
for (let i=0; i<files.length; i++) {
completeSize += files[0].size;
@ -535,9 +539,9 @@ class ReceiveFileDialog extends ReceiveDialog {
filename = `PairDrop_files_${year+month+date}_${hours+minutes}.zip`;
}
this.$receiveTitleNode.textContent = title;
this.$fileDescriptionNode.textContent = description;
this.$fileSizeNode.textContent = size;
this.$shareOrDownloadBtn.download = filename;
if ((window.iOS || window.android) && !!navigator.share && navigator.canShare({files})) {
this.$shareOrDownloadBtn.innerText = "Share";
@ -549,6 +553,7 @@ class ReceiveFileDialog extends ReceiveDialog {
this.$shareOrDownloadBtn.addEventListener("click", this.continueCallback);
} else {
this.$shareOrDownloadBtn.innerText = "Download";
this.$shareOrDownloadBtn.download = filename;
this.$shareOrDownloadBtn.href = url;
}