From 3c3f632890c9f5bfa598c0c978a01515a66d5a9b Mon Sep 17 00:00:00 2001 From: Clairton Rodrigo Heinzen Date: Sun, 29 Sep 2024 18:24:26 -0300 Subject: [PATCH] fix: retry 5 time to show attachment --- .../conversation/bubble/ImageAudioVideo.vue | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/app/javascript/dashboard/components/widgets/conversation/bubble/ImageAudioVideo.vue b/app/javascript/dashboard/components/widgets/conversation/bubble/ImageAudioVideo.vue index 41ba5b0c86dcd..5792a0b4fb5d3 100644 --- a/app/javascript/dashboard/components/widgets/conversation/bubble/ImageAudioVideo.vue +++ b/app/javascript/dashboard/components/widgets/conversation/bubble/ImageAudioVideo.vue @@ -29,8 +29,11 @@ export default { data() { return { show: false, - isImageError: false, - isImageErrorDelay: false, + isAttachmentError: false, + countAttachmentRetry: 0, + maxAttachmentRetry: 5, + retyAttachmentDelay: 1000, + isAttachmentLoading: false, }; }, computed: { @@ -76,7 +79,7 @@ export default { }, watch: { attachment() { - this.isImageError = false; + this.isAttachmentError = false; }, }, methods: { @@ -90,15 +93,19 @@ export default { } this.show = true; }, - onImgError() { - this.isImageError = true; + onAttachmentError() { + this.isAttachmentError = true; this.$emit('error'); }, - onImgErrorDelay() { + onAttachmentErrorDelay() { + if (this.countAttachmentRetry >= this.maxAttachmentRetry) { + return; + } + this.countAttachmentRetry += 1; + this.isAttachmentLoading = true; setTimeout(() => { - this.isImageErrorDelay = true; - this.$emit('error'); - }, 1000); + this.isAttachmentLoading = false; + }, this.retyAttachmentDelay * this.countAttachmentRetry); }, }, }; @@ -107,32 +114,28 @@ export default {