Change sub filter to ignore unchanged l2 subs

This commit is contained in:
Daniel Compton 2018-01-31 01:07:55 +13:00
parent d652ef17e3
commit d5060fc814
6 changed files with 34 additions and 16 deletions

View File

@ -14,6 +14,7 @@ This version requires re-frame 0.10.4 to make use of the newly added Event panel
### Changed
* In the subs panel "Ignore **n** layer 2 subs" is now "Ignore **n** unchanged layer 2 subs". This is a more useful filter, as you can filter out noisy layer 2 subscriptions, while still seeing the changes that do happen to layer 2 subs.
* The version of Garden that re-frame-trace uses is now bundled as a source dependency so you should no longer get conflicts if you use Garden 2.
* Refactored re-frame-trace trace parsing internals to incrementally parse new traces.
* Clicking on a trace's expanded information now prints the entire trace to the console instead of just the tags.

View File

@ -593,7 +593,7 @@
;;
(rf/reg-event-db
:subs/ignore-unchanged-subs?
:subs/ignore-unchanged-l2-subs?
[(rf/path [:subs :ignore-unchanged-subs?])]
(fn [_ [_ ignore?]]
ignore?))

View File

@ -162,12 +162,12 @@
(= :render (:op-type trace)))
(defn unchanged-l2-subscription? [sub]
;; TODO: check if value changed
(and
(= :re-run (:type sub))
(= 2 (:layer sub))
;; Show any subs that ran multiple times
(nil? (:run-times sub))))
(and (contains? sub :previous-value)
(contains? sub :value)
(= (:previous-value sub) (:value sub)))))
(defn finish-run? [event]

View File

@ -464,7 +464,7 @@
(rf/reg-sub
:subs/visible-subs
:<- [:subs/all-subs]
:<- [:subs/ignore-unchanged-subs?]
:<- [:subs/ignore-unchanged-l2-subs?]
(fn [[all-subs ignore-unchanged-l2?]]
(if ignore-unchanged-l2?
(remove metam/unchanged-l2-subscription? all-subs)
@ -509,7 +509,7 @@
(count (filter metam/unchanged-l2-subscription? subs))))
(rf/reg-sub
:subs/ignore-unchanged-subs?
:subs/ignore-unchanged-l2-subs?
:<- [:subs/root]
(fn [subs _]
(:ignore-unchanged-subs? subs true)))

View File

@ -29,3 +29,21 @@
([label x]
(js/console.log label x)
x))
(defn pluralize
"Return a pluralized phrase, appending an s to the singular form if no plural is provided.
For example:
(pluralize 5 \"month\") => \"5 months\"
(pluralize 1 \"month\") => \"1 month\"
(pluralize 1 \"radius\" \"radii\") => \"1 radius\"
(pluralize 9 \"radius\" \"radii\") => \"9 radii\"
From https://github.com/flatland/useful/blob/194950/src/flatland/useful/string.clj#L25-L33"
[num singular & [plural]]
(str num " " (if (= 1 num) singular (or plural (str singular "s")))))
(defn pluralize-
"Same as pluralize, but doesn't prepend the number to the pluralized string."
[num singular & [plural]]
(if (= 1 num)
singular
(or plural (str singular "s"))))

View File

@ -56,7 +56,7 @@
re-run-count (rf/subscribe [:subs/re-run-count])
destroyed-count (rf/subscribe [:subs/destroyed-count])
not-run-count (rf/subscribe [:subs/not-run-count])
ignore-unchanged? (rf/subscribe [:subs/ignore-unchanged-subs?])
ignore-unchanged-l2-subs? (rf/subscribe [:subs/ignore-unchanged-l2-subs?])
ignore-unchanged-l2-count (rf/subscribe [:subs/unchanged-l2-subs-count])]
[rc/h-box
:justify :between
@ -89,13 +89,12 @@
:border "1px solid #e3e9ed"
:border-radius border-radius}
:children [[rc/checkbox
:model ignore-unchanged?
;; TODO: change from l2 subs to ignored l2 subs
:label [:span "Ignore " [:b {:style {:font-weight "700"}} @ignore-unchanged-l2-count] #_" unchanged" [:br]
[rc/link {:label "layer 2 subs"
:model ignore-unchanged-l2-subs?
:label [:span "Ignore " [:b {:style {:font-weight "700"}} @ignore-unchanged-l2-count] " unchanged" [:br]
[rc/link {:label (str "layer 2 " (utils/pluralize- @ignore-unchanged-l2-count "sub"))
:href "https://github.com/Day8/re-frame-trace/blob/master/docs/HyperlinkedInformation/UnchangedLayer2.md"}]]
:style {:margin-top "6px"}
:on-change #(rf/dispatch [:subs/ignore-unchanged-subs? %])]]]]]))
:on-change #(rf/dispatch [:subs/ignore-unchanged-l2-subs? %])]]]]]))
(defn pod-header [{:keys [id type layer path open? diff? run-times]}]
[rc/h-box
@ -270,10 +269,10 @@
(defn render []
[]
[rc/v-box
:size "1"
:style {:margin-right common/gs-19s
;:overflow "hidden"
}
:size "1"
:style {:margin-right common/gs-19s
;:overflow "hidden"
}
:children [[panel-header]
[pod-section]
[rc/gap-f :size pod-gap]