From 35f47d9063c806ea5c9ca540836cf274a0bc820b Mon Sep 17 00:00:00 2001 From: schlagmichdoch Date: Wed, 17 Apr 2024 20:38:33 +0200 Subject: [PATCH] Fix inner text being cleared when viewing next received text from queue + prevent skipping of queue entry when timing is bad by checking for existing timeout Co-authored-by: klmkyo --- public/scripts/ui.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/public/scripts/ui.js b/public/scripts/ui.js index af355241..c9bd3658 100644 --- a/public/scripts/ui.js +++ b/public/scripts/ui.js @@ -2017,6 +2017,7 @@ class ReceiveTextDialog extends Dialog { this.$displayName = this.$el.querySelector('.display-name'); this._receiveTextQueue = []; + this._hideTimeout = null; } selectionEmpty() { @@ -2040,17 +2041,12 @@ class ReceiveTextDialog extends Dialog { this._setDocumentTitleMessages(); changeFavicon("images/favicon-96x96-notification.png"); - if (this.isShown()) return; + if (this.isShown() || this._hideTimeout) return; this._dequeueRequests(); } _dequeueRequests() { - if (!this._receiveTextQueue.length) { - this.$text.innerHTML = ""; - return; - } - this._setDocumentTitleMessages(); changeFavicon("images/favicon-96x96-notification.png"); @@ -2145,9 +2141,16 @@ class ReceiveTextDialog extends Dialog { hide() { super.hide(); - setTimeout(() => { - this._dequeueRequests(); - this.$text.innerHTML = ""; + + // If queue is empty -> clear text field | else -> open next message + this._hideTimeout = setTimeout(() => { + if (!this._receiveTextQueue.length) { + this.$text.innerHTML = ""; + } + else { + this._dequeueRequests(); + } + this._hideTimeout = null; }, 500); } }