Delay toast on SSE communication failure by one second (#1993)

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
pull/2032/head
Florian Hotze 2023-08-19 19:57:00 +02:00 committed by GitHub
parent 55b825c3de
commit a08c347b95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 3 deletions

View File

@ -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()