From b21b83c18254e993b3936ec21c3d8b55864458c3 Mon Sep 17 00:00:00 2001 From: Daniel Compton Date: Tue, 7 Nov 2017 14:03:18 +1300 Subject: [PATCH] Remove paths on click --- src/day8/re_frame/trace/events.cljs | 7 +++++++ src/day8/re_frame/trace/panels/app_db.cljs | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/day8/re_frame/trace/events.cljs b/src/day8/re_frame/trace/events.cljs index 045db0d..3570ac1 100644 --- a/src/day8/re_frame/trace/events.cljs +++ b/src/day8/re_frame/trace/events.cljs @@ -81,3 +81,10 @@ (fn [db [_ paths]] (localstorage/save! "app-db-paths" paths) (assoc-in db [:app-db :paths] paths))) + +(rf/reg-event-db + :app-db/remove-path + (fn [db [_ path]] + (let [new-db (update-in db [:app-db :paths] disj path)] + (localstorage/save! "app-db-paths" (get-in new-db [:app-db :paths])) + new-db))) diff --git a/src/day8/re_frame/trace/panels/app_db.cljs b/src/day8/re_frame/trace/panels/app_db.cljs index f842a49..9b07440 100644 --- a/src/day8/re_frame/trace/panels/app_db.cljs +++ b/src/day8/re_frame/trace/panels/app_db.cljs @@ -144,7 +144,7 @@ [:div.subtree [subtree (get-in @data path) - [:button.subtree-button {:on-click #(swap! subtree-paths disj path)} + [:button.subtree-button {:on-click #(rf/dispatch [:app-db/remove-path path])} [:span.subtree-button-string (str path)]]]]]) @subtree-paths))]