From 0c336605f393d8ad8c7a71a1efb25bc179a6ce76 Mon Sep 17 00:00:00 2001 From: Saskia Lindner Date: Fri, 25 Aug 2017 11:23:07 +0200 Subject: [PATCH] Save traces and detail expansions to localstorage fixes #54 --- src/day8/re_frame/trace.cljs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/day8/re_frame/trace.cljs b/src/day8/re_frame/trace.cljs index 96d99fb..7ac5b3c 100644 --- a/src/day8/re_frame/trace.cljs +++ b/src/day8/re_frame/trace.cljs @@ -94,7 +94,8 @@ (real-schedule))))) -(def traces (interop/ratom [])) +(def traces (interop/ratom (localstorage/get "traces" []))) + (defn log-trace? [trace] (let [rendering? (= (:op-type trace) :render)] (if-not rendering? @@ -191,7 +192,15 @@ filter-items (r/atom (localstorage/get "filter-items" [])) filter-type (r/atom :contains) input-error (r/atom false) - trace-detail-expansions (r/atom {:show-all? false :overrides {}})] + trace-detail-expansions (r/atom (localstorage/get "trace-detail-expansion" {:show-all? false :overrides {}}))] + (add-watch traces + :update-traces + (fn [_ _ _ new-state] + (localstorage/save! "traces" new-state))) + (add-watch trace-detail-expansions + :update-trace-detail-expansions + (fn [_ _ _ new-state] + (localstorage/save! "trace-detail-expansion" new-state))) (add-watch filter-items :update-localstorage (fn [_ _ _ new-state]