Use when-not instead of single branch if-not and do

This commit is contained in:
Daniel Compton 2017-09-01 14:28:51 +12:00
parent 8e3279c39c
commit b345eb824e
1 changed files with 12 additions and 13 deletions

View File

@ -148,19 +148,18 @@
(defn add-filter [filter-items filter-input filter-type]
;; prevent duplicate filter strings
(if-not (some #(= filter-input (:query %)) @filter-items)
(do
;; if existing, remove prior filter for :slower-than
(when (and (= :slower-than filter-type)
(some #(= filter-type (:filter-type %)) @filter-items))
(swap! filter-items (fn [item]
(remove #(= :slower-than (:filter-type %)) item))))
;; add new filter
(swap! filter-items conj {:id (random-uuid)
:query (if (= filter-type :contains)
(str/lower-case filter-input)
(js/parseFloat filter-input))
:filter-type filter-type}))))
(when-not (some #(= filter-input (:query %)) @filter-items)
;; if existing, remove prior filter for :slower-than
(when (and (= :slower-than filter-type)
(some #(= filter-type (:filter-type %)) @filter-items))
(swap! filter-items (fn [item]
(remove #(= :slower-than (:filter-type %)) item))))
;; add new filter
(swap! filter-items conj {:id (random-uuid)
:query (if (= filter-type :contains)
(str/lower-case filter-input)
(js/parseFloat filter-input))
:filter-type filter-type})))
(defn render-traces [showing-traces filter-items filter-input trace-detail-expansions]
(doall