From a08c347b95541dbb27d75936e0e78732f6c1e5ca Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Sat, 19 Aug 2023 19:57:00 +0200 Subject: [PATCH] Delay toast on SSE communication failure by one second (#1993) Signed-off-by: Florian Hotze --- bundles/org.openhab.ui/web/src/components/app.vue | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.ui/web/src/components/app.vue b/bundles/org.openhab.ui/web/src/components/app.vue index 8825dc14be..91e651a28b 100644 --- a/bundles/org.openhab.ui/web/src/components/app.vue +++ b/bundles/org.openhab.ui/web/src/components/app.vue @@ -382,7 +382,8 @@ export default { showDeveloperSidebar: false, currentUrl: '', - communicationFailureToast: null + communicationFailureToast: null, + communicationFailureTimeoutId: null } }, computed: { @@ -785,9 +786,16 @@ export default { if (mutation.type === 'sseConnected') { if (!window.OHApp && this.$f7) { if (mutation.payload === false) { - if (this.communicationFailureToast === null) this.communicationFailureToast = this.displayFailureToast(this.$t('error.communicationFailure'), true, false) - this.communicationFailureToast.open() + if (this.communicationFailureToast === null) { + this.communicationFailureTimeoutId = setTimeout(() => { + if (this.communicationFailureToast !== null) return + this.communicationFailureToast = this.displayFailureToast(this.$t('error.communicationFailure'), true, false) + this.communicationFailureToast.open() + this.communicationFailureTimeoutId = null + }, 1000) + } } else if (mutation.payload === true) { + if (this.communicationFailureTimeoutId !== null) clearTimeout(this.communicationFailureTimeoutId) if (this.communicationFailureToast !== null) { this.communicationFailureToast.close() this.communicationFailureToast.destroy()