From dcc2f0c607cf331813d66a8ce473aaff3f8621f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Mon, 20 Aug 2018 17:10:27 +0100 Subject: [PATCH] fix(ui): check for duplicated values in AlertStore.filters.replaceFilter --- ui/src/Stores/AlertStore.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ui/src/Stores/AlertStore.js b/ui/src/Stores/AlertStore.js index c2235b2ea..d8c3ee582 100644 --- a/ui/src/Stores/AlertStore.js +++ b/ui/src/Stores/AlertStore.js @@ -102,8 +102,15 @@ class AlertStore { replaceFilter(oldRaw, newRaw) { const index = this.values.findIndex(e => e.raw === oldRaw); if (index >= 0) { - this.values[index] = newUnappliedFilter(newRaw); - UpdateLocationSearch({ q: this.values.map(f => f.raw) }); + // first check if we would create a duplicated filter + if (this.values.findIndex(e => e.raw === newRaw) >= 0) { + // we already have newRaw, simply drop oldRaw + this.removeFilter(oldRaw); + } else { + // no dups, continue with a swap + this.values[index] = newUnappliedFilter(newRaw); + UpdateLocationSearch({ q: this.values.map(f => f.raw) }); + } } }, setFilters(raws) {