mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-20 23:16:13 -04:00
touched UX to make receive dialogs more intuitive. closes #40
This commit is contained in:
parent
12a2fc1b0a
commit
40c0735c90
2 changed files with 34 additions and 18 deletions
|
@ -590,24 +590,32 @@ class ReceiveFileDialog extends ReceiveDialog {
|
||||||
|
|
||||||
if (shareInsteadOfDownload) {
|
if (shareInsteadOfDownload) {
|
||||||
this.$shareOrDownloadBtn.innerText = "Share";
|
this.$shareOrDownloadBtn.innerText = "Share";
|
||||||
this.continueCallback = async _ => {
|
this.continue = _ => {
|
||||||
navigator.share({
|
navigator.share({files: files})
|
||||||
files: files
|
.catch(err => console.error(err));
|
||||||
}).catch(err => console.error(err));
|
}
|
||||||
|
this.continueCallback = _ => this.continue();
|
||||||
|
} else {
|
||||||
|
this.$shareOrDownloadBtn.innerText = "Download again";
|
||||||
|
this.continue = _ => {
|
||||||
|
let tmpBtn = document.createElement("a");
|
||||||
|
tmpBtn.download = filenameDownload;
|
||||||
|
tmpBtn.href = url;
|
||||||
|
tmpBtn.click();
|
||||||
|
};
|
||||||
|
this.continueCallback = _ => {
|
||||||
|
this.continue();
|
||||||
|
this.hide();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
this.$shareOrDownloadBtn.addEventListener("click", this.continueCallback);
|
this.$shareOrDownloadBtn.addEventListener("click", this.continueCallback);
|
||||||
} else {
|
|
||||||
this.$shareOrDownloadBtn.innerText = "Download";
|
|
||||||
this.$shareOrDownloadBtn.download = filenameDownload;
|
|
||||||
this.$shareOrDownloadBtn.href = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.createPreviewElement(files[0]).finally(_ => {
|
this.createPreviewElement(files[0]).finally(_ => {
|
||||||
document.title = `PairDrop - ${files.length} Files received`;
|
document.title = `PairDrop - ${files.length} Files received`;
|
||||||
document.changeFavicon("images/favicon-96x96-notification.png");
|
document.changeFavicon("images/favicon-96x96-notification.png");
|
||||||
this.show();
|
this.show();
|
||||||
Events.fire('set-progress', {peerId: peerId, progress: 1, status: 'process'})
|
Events.fire('set-progress', {peerId: peerId, progress: 1, status: 'process'})
|
||||||
this.$shareOrDownloadBtn.click();
|
this.continue();
|
||||||
}).catch(r => console.error(r));
|
}).catch(r => console.error(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -591,24 +591,32 @@ class ReceiveFileDialog extends ReceiveDialog {
|
||||||
|
|
||||||
if (shareInsteadOfDownload) {
|
if (shareInsteadOfDownload) {
|
||||||
this.$shareOrDownloadBtn.innerText = "Share";
|
this.$shareOrDownloadBtn.innerText = "Share";
|
||||||
this.continueCallback = async _ => {
|
this.continue = _ => {
|
||||||
navigator.share({
|
navigator.share({files: files})
|
||||||
files: files
|
.catch(err => console.error(err));
|
||||||
}).catch(err => console.error(err));
|
}
|
||||||
|
this.continueCallback = _ => this.continue();
|
||||||
|
} else {
|
||||||
|
this.$shareOrDownloadBtn.innerText = "Download again";
|
||||||
|
this.continue = _ => {
|
||||||
|
let tmpBtn = document.createElement("a");
|
||||||
|
tmpBtn.download = filenameDownload;
|
||||||
|
tmpBtn.href = url;
|
||||||
|
tmpBtn.click();
|
||||||
|
};
|
||||||
|
this.continueCallback = _ => {
|
||||||
|
this.continue();
|
||||||
|
this.hide();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
this.$shareOrDownloadBtn.addEventListener("click", this.continueCallback);
|
this.$shareOrDownloadBtn.addEventListener("click", this.continueCallback);
|
||||||
} else {
|
|
||||||
this.$shareOrDownloadBtn.innerText = "Download";
|
|
||||||
this.$shareOrDownloadBtn.download = filenameDownload;
|
|
||||||
this.$shareOrDownloadBtn.href = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.createPreviewElement(files[0]).finally(_ => {
|
this.createPreviewElement(files[0]).finally(_ => {
|
||||||
document.title = `PairDrop - ${files.length} Files received`;
|
document.title = `PairDrop - ${files.length} Files received`;
|
||||||
document.changeFavicon("images/favicon-96x96-notification.png");
|
document.changeFavicon("images/favicon-96x96-notification.png");
|
||||||
this.show();
|
this.show();
|
||||||
Events.fire('set-progress', {peerId: peerId, progress: 1, status: 'process'})
|
Events.fire('set-progress', {peerId: peerId, progress: 1, status: 'process'})
|
||||||
this.$shareOrDownloadBtn.click();
|
this.continue();
|
||||||
}).catch(r => console.error(r));
|
}).catch(r => console.error(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue