From 28c7fcd7a221f0d8ad9e02da3996695b0d0c9ce5 Mon Sep 17 00:00:00 2001 From: schlagmichdoch Date: Fri, 20 Oct 2023 16:36:03 +0200 Subject: [PATCH] fix header not showing on snapdrop-android app --- public/scripts/ui.js | 21 ++++++++------------- public_included_ws_fallback/scripts/ui.js | 21 ++++++++------------- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/public/scripts/ui.js b/public/scripts/ui.js index 0dc5961..c124d2b 100644 --- a/public/scripts/ui.js +++ b/public/scripts/ui.js @@ -70,21 +70,17 @@ class PeersUI { this.$header = document.querySelector('header.opacity-0'); Events.on('header-evaluated', e => this._fadeInHeader(e.detail)); - // wait for evaluation of notification, install and edit-paired-devices buttons - this.evaluateHeaderCount = 3; - if (!('Notification' in window)) this.evaluateHeaderCount -= 1; - if ( - !('BeforeInstallPromptEvent' in window) || - ('BeforeInstallPromptEvent' in window && window.matchMedia('(display-mode: minimal-ui)').matches) - ) { - this.evaluateHeaderCount -= 1; - } + // wait for evaluation of notification and edit-paired-devices buttons + this.evaluateHeader = ["notification", "edit-paired-devices"]; + + if (!('Notification' in window)) this.evaluateHeader.splice(this.evaluateHeader.indexOf("notification"), 1); } _fadeInHeader(id) { - this.evaluateHeaderCount -= 1; - console.log(`Header btn ${id} evaluated. ${this.evaluateHeaderCount} to go.`); - if (this.evaluateHeaderCount !== 0) return; + this.evaluateHeader.splice(this.evaluateHeader.indexOf(id), 1); + console.log(`Header btn ${id} evaluated. ${this.evaluateHeader.length} to go.`); + + if (this.evaluateHeader.length !== 0) return; this.$header.classList.remove('opacity-0'); } @@ -2838,7 +2834,6 @@ window.addEventListener('beforeinstallprompt', installEvent => { installBtn.setAttribute('hidden', ''); installEvent.prompt(); }); - Events.fire('header-evaluated', 'install'); } return installEvent.preventDefault(); }); \ No newline at end of file diff --git a/public_included_ws_fallback/scripts/ui.js b/public_included_ws_fallback/scripts/ui.js index 11ee54c..1346f67 100644 --- a/public_included_ws_fallback/scripts/ui.js +++ b/public_included_ws_fallback/scripts/ui.js @@ -70,21 +70,17 @@ class PeersUI { this.$header = document.querySelector('header.opacity-0'); Events.on('header-evaluated', e => this._fadeInHeader(e.detail)); - // wait for evaluation of notification, install and edit-paired-devices buttons - this.evaluateHeaderCount = 3; - if (!('Notification' in window)) this.evaluateHeaderCount -= 1; - if ( - !('BeforeInstallPromptEvent' in window) || - ('BeforeInstallPromptEvent' in window && window.matchMedia('(display-mode: minimal-ui)').matches) - ) { - this.evaluateHeaderCount -= 1; - } + // wait for evaluation of notification and edit-paired-devices buttons + this.evaluateHeader = ["notification", "edit-paired-devices"]; + + if (!('Notification' in window)) this.evaluateHeader.splice(this.evaluateHeader.indexOf("notification"), 1); } _fadeInHeader(id) { - this.evaluateHeaderCount -= 1; - console.log(`Header btn ${id} evaluated. ${this.evaluateHeaderCount} to go.`); - if (this.evaluateHeaderCount !== 0) return; + this.evaluateHeader.splice(this.evaluateHeader.indexOf(id), 1); + console.log(`Header btn ${id} evaluated. ${this.evaluateHeader.length} to go.`); + + if (this.evaluateHeader.length !== 0) return; this.$header.classList.remove('opacity-0'); } @@ -2840,7 +2836,6 @@ window.addEventListener('beforeinstallprompt', installEvent => { installBtn.setAttribute('hidden', ''); installEvent.prompt(); }); - Events.fire('header-evaluated', 'install'); } return installEvent.preventDefault(); }); \ No newline at end of file