mirror of
https://github.com/status-im/re-frame-10x.git
synced 2025-01-30 16:14:57 +00:00
Handle initial state when there are no previous traces
(reduce conj existing ...) was returning a seq instead of a vector for the first received traces, because it was existing was nil instead of the empty vector.
This commit is contained in:
parent
6c5623a5d0
commit
af4afbae88
@ -485,22 +485,23 @@
|
|||||||
(rf/reg-event-db
|
(rf/reg-event-db
|
||||||
:epochs/receive-new-traces
|
:epochs/receive-new-traces
|
||||||
(fn [db [_ new-traces]]
|
(fn [db [_ new-traces]]
|
||||||
(when-let [new-traces (->> (filter log-trace? new-traces)
|
(if-let [new-traces (->> (filter log-trace? new-traces)
|
||||||
(sort-by :id))]
|
(sort-by :id))]
|
||||||
(let [number-of-epochs-to-retain (get-in db [:settings :number-of-epochs])
|
(let [number-of-epochs-to-retain (get-in db [:settings :number-of-epochs])
|
||||||
events-to-ignore (->> (get-in db [:settings :ignored-events]) vals (map :event-id) set)
|
events-to-ignore (->> (get-in db [:settings :ignored-events]) vals (map :event-id) set)
|
||||||
existing-traces (get-in db [:traces :all-traces])
|
previous-traces (get-in db [:traces :all-traces] [])
|
||||||
new-traces (reduce conj existing-traces new-traces)
|
all-traces (reduce conj previous-traces new-traces)
|
||||||
matches (:matches (metam/parse-traces new-traces))
|
matches (:matches (metam/parse-traces all-traces))
|
||||||
matches (remove (fn [match]
|
matches (remove (fn [match]
|
||||||
(let [event (get-in (metam/matched-event match) [:tags :event])]
|
(let [event (get-in (metam/matched-event match) [:tags :event])]
|
||||||
(contains? events-to-ignore (first event)))) matches)
|
(contains? events-to-ignore (first event)))) matches)
|
||||||
retained-epochs (take-last number-of-epochs-to-retain matches)
|
retained-epochs (take-last number-of-epochs-to-retain matches)
|
||||||
first-id-to-retain (:id (ffirst retained-epochs))
|
first-id-to-retain (:id (ffirst retained-epochs))
|
||||||
new-traces (into [] (drop-while #(< (:id %) first-id-to-retain)) new-traces)]
|
retained-traces (into [] (drop-while #(< (:id %) first-id-to-retain)) all-traces)]
|
||||||
(rf/dispatch [:traces/update-traces new-traces])
|
(rf/dispatch [:epochs/update-epochs {:matches retained-epochs}])
|
||||||
(rf/dispatch [:epochs/update-epochs {:matches retained-epochs}])))
|
(assoc-in db [:traces :all-traces] retained-traces))
|
||||||
db))
|
;; Else
|
||||||
|
db)))
|
||||||
|
|
||||||
(rf/reg-event-db
|
(rf/reg-event-db
|
||||||
:epochs/update-epochs
|
:epochs/update-epochs
|
||||||
@ -544,12 +545,6 @@
|
|||||||
(re-frame.trace/reset-tracing!)
|
(re-frame.trace/reset-tracing!)
|
||||||
(dissoc db :epochs :traces)))
|
(dissoc db :epochs :traces)))
|
||||||
|
|
||||||
(rf/reg-event-db
|
|
||||||
:traces/update-traces
|
|
||||||
[(rf/path [:traces :all-traces])]
|
|
||||||
(fn [_ [_ traces]]
|
|
||||||
traces))
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(rf/reg-event-db
|
(rf/reg-event-db
|
||||||
|
Loading…
x
Reference in New Issue
Block a user