From 40c0735c906de995d08536b15ac7658fe59aa747 Mon Sep 17 00:00:00 2001 From: schlagmichdoch Date: Wed, 22 Feb 2023 03:00:29 +0100 Subject: [PATCH] touched UX to make receive dialogs more intuitive. closes #40 --- public/scripts/ui.js | 26 +++++++++++++++-------- public_included_ws_fallback/scripts/ui.js | 26 +++++++++++++++-------- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/public/scripts/ui.js b/public/scripts/ui.js index f829f32..161f7b3 100644 --- a/public/scripts/ui.js +++ b/public/scripts/ui.js @@ -590,24 +590,32 @@ class ReceiveFileDialog extends ReceiveDialog { if (shareInsteadOfDownload) { this.$shareOrDownloadBtn.innerText = "Share"; - this.continueCallback = async _ => { - navigator.share({ - files: files - }).catch(err => console.error(err)); + this.continue = _ => { + navigator.share({files: files}) + .catch(err => console.error(err)); } - this.$shareOrDownloadBtn.addEventListener("click", this.continueCallback); + this.continueCallback = _ => this.continue(); } else { - this.$shareOrDownloadBtn.innerText = "Download"; - this.$shareOrDownloadBtn.download = filenameDownload; - this.$shareOrDownloadBtn.href = url; + 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.createPreviewElement(files[0]).finally(_ => { document.title = `PairDrop - ${files.length} Files received`; document.changeFavicon("images/favicon-96x96-notification.png"); this.show(); Events.fire('set-progress', {peerId: peerId, progress: 1, status: 'process'}) - this.$shareOrDownloadBtn.click(); + this.continue(); }).catch(r => console.error(r)); } diff --git a/public_included_ws_fallback/scripts/ui.js b/public_included_ws_fallback/scripts/ui.js index 796230f..8e1a306 100644 --- a/public_included_ws_fallback/scripts/ui.js +++ b/public_included_ws_fallback/scripts/ui.js @@ -591,24 +591,32 @@ class ReceiveFileDialog extends ReceiveDialog { if (shareInsteadOfDownload) { this.$shareOrDownloadBtn.innerText = "Share"; - this.continueCallback = async _ => { - navigator.share({ - files: files - }).catch(err => console.error(err)); + this.continue = _ => { + navigator.share({files: files}) + .catch(err => console.error(err)); } - this.$shareOrDownloadBtn.addEventListener("click", this.continueCallback); + this.continueCallback = _ => this.continue(); } else { - this.$shareOrDownloadBtn.innerText = "Download"; - this.$shareOrDownloadBtn.download = filenameDownload; - this.$shareOrDownloadBtn.href = url; + 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.createPreviewElement(files[0]).finally(_ => { document.title = `PairDrop - ${files.length} Files received`; document.changeFavicon("images/favicon-96x96-notification.png"); this.show(); Events.fire('set-progress', {peerId: peerId, progress: 1, status: 'process'}) - this.$shareOrDownloadBtn.click(); + this.continue(); }).catch(r => console.error(r)); }