Skip to content

Commit

Permalink
Delay toast on SSE communication failure by one second (#1993)
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
  • Loading branch information
florian-h05 authored Aug 19, 2023
1 parent 55b825c commit a08c347
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions bundles/org.openhab.ui/web/src/components/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ export default {
showDeveloperSidebar: false,
currentUrl: '',
communicationFailureToast: null
communicationFailureToast: null,
communicationFailureTimeoutId: null
}
},
computed: {
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit a08c347

Please sign in to comment.