From 6c38ada28199131e88154714e8c93b9dd88538e7 Mon Sep 17 00:00:00 2001 From: Cindy Chang Date: Fri, 9 Aug 2024 14:54:22 +0800 Subject: [PATCH] sonar 1 left --- src/components/Discover/Map/Filter/Funnel.vue | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/components/Discover/Map/Filter/Funnel.vue b/src/components/Discover/Map/Filter/Funnel.vue index 0847a87..b86ca7f 100644 --- a/src/components/Discover/Map/Filter/Funnel.vue +++ b/src/components/Discover/Map/Filter/Funnel.vue @@ -42,6 +42,7 @@ import { storeToRefs } from 'pinia'; import LoadingStore from '@/stores/loading.js'; import AllMapDataStore from '@/stores/allMapData.js'; +import { delaySecond, } from '@/utils/timeUtil.js'; export default { setup() { @@ -97,8 +98,9 @@ export default { if(!this.postRuleData?.length) return this.$toast.error('Not selected'); await this.allMapDataStore.checkHasResult(); // 後端快速檢查有沒有結果 - if(this.hasResultRule === null) return; - else if(this.hasResultRule) { + if(this.hasResultRule === null) { + return; + } else if(this.hasResultRule) { this.isLoading = true; await this.allMapDataStore.addTempFilterId(); await this.allMapDataStore.getAllMapData(); @@ -109,12 +111,14 @@ export default { await this.$emit('submit-all'); this.isLoading = false; this.$toast.success('Filter(s) applied.'); - }else { - this.isLoading = true; - await new Promise(resolve => setTimeout(resolve, 1000)); - this.isLoading = false; - this.$toast.warning('No result.'); - }; + return; + } + + // sonar-qube "This statement will not be executed conditionally" + this.isLoading = true; + await delaySecond(1); + this.isLoading = false; + this.$toast.warning('No result.'); }, } }