From 49c20b184017a2a9867e0c27ea6b0401c626f092 Mon Sep 17 00:00:00 2001 From: Suven-p Date: Fri, 1 Nov 2024 16:38:47 +0545 Subject: [PATCH] Refactor: Remove checks for null --- src/components/MonitorList.vue | 10 ++--- src/components/MonitorListFilter.vue | 58 +++++++++++----------------- 2 files changed, 27 insertions(+), 41 deletions(-) diff --git a/src/components/MonitorList.vue b/src/components/MonitorList.vue index 49be97ed5..88450948b 100644 --- a/src/components/MonitorList.vue +++ b/src/components/MonitorList.vue @@ -294,9 +294,7 @@ export default { this.$router.replace({ query: { ...this.$route.query, - status: newFilter.status, - active: newFilter.active, - tags: newFilter.tags, + ...newFilter, }, }); }, @@ -388,7 +386,7 @@ export default { // filter by status let statusMatch = true; - if (this.filterState.status != null && this.filterState.status.length > 0) { + if (this.filterState.status.length > 0) { if (monitor.id in this.$root.lastHeartbeatList && this.$root.lastHeartbeatList[monitor.id]) { monitor.status = this.$root.lastHeartbeatList[monitor.id].status; } @@ -397,13 +395,13 @@ export default { // filter by active let activeMatch = true; - if (this.filterState.active != null && this.filterState.active.length > 0) { + if (this.filterState.active.length > 0) { activeMatch = this.filterState.active.includes(monitor.active); } // filter by tags let tagsMatch = true; - if (this.filterState.tags != null && this.filterState.tags.length > 0) { + if (this.filterState.tags.length > 0) { tagsMatch = monitor.tags.map(tag => tag.tag_id) // convert to array of tag IDs .filter(monitorTagId => this.filterState.tags.includes(monitorTagId)) // perform Array Intersaction between filter and monitor's tags .length > 0; diff --git a/src/components/MonitorListFilter.vue b/src/components/MonitorListFilter.vue index 251551006..5f223d60c 100644 --- a/src/components/MonitorListFilter.vue +++ b/src/components/MonitorListFilter.vue @@ -14,10 +14,10 @@ - + - +