Save and load JSONML expansions to localstorage
This commit is contained in:
parent
87e5679ebb
commit
a6bf2be052
|
@ -7,13 +7,14 @@
|
|||
show-panel? (localstorage/get "show-panel" false)
|
||||
selected-tab (localstorage/get "selected-tab" :traces)
|
||||
filter-items (localstorage/get "filter-items" [])
|
||||
app-db-paths (localstorage/get "app-db-paths" '())]
|
||||
app-db-paths (localstorage/get "app-db-paths" '())
|
||||
json-ml-paths (localstorage/get "app-db-json-ml-expansions" #{})]
|
||||
(rf/dispatch [:settings/panel-width% panel-width%])
|
||||
(rf/dispatch [:settings/show-panel? show-panel?])
|
||||
(rf/dispatch [:settings/selected-tab selected-tab])
|
||||
(rf/dispatch [:traces/filter-items filter-items])
|
||||
(rf/dispatch [:app-db/paths app-db-paths])
|
||||
(rf/dispatch [:app-db/set-json-ml-paths #{}])
|
||||
(rf/dispatch [:app-db/set-json-ml-paths json-ml-paths])
|
||||
(rf/dispatch [:global/add-unload-hook])
|
||||
(when show-panel?
|
||||
(rf/dispatch [:global/enable-tracing]))))
|
||||
|
|
|
@ -186,13 +186,17 @@
|
|||
|
||||
(rf/reg-event-db
|
||||
:app-db/set-json-ml-paths
|
||||
[(rf/path [:app-db :json-ml-expansions])]
|
||||
(fn [db [_ paths]]
|
||||
(assoc-in db [:app-db :json-ml-paths] paths)))
|
||||
(localstorage/save! "app-db-json-ml-expansions" paths)
|
||||
paths))
|
||||
|
||||
(rf/reg-event-db
|
||||
:app-db/toggle-expansion
|
||||
[(rf/path [:app-db :json-ml-paths])]
|
||||
[(rf/path [:app-db :json-ml-expansions])]
|
||||
(fn [paths [_ path]]
|
||||
(if (contains? paths path)
|
||||
(disj paths path)
|
||||
(conj paths path))))
|
||||
(let [new-paths (if (contains? paths path)
|
||||
(disj paths path)
|
||||
(conj paths path))]
|
||||
(localstorage/save! "app-db-json-ml-expansions" new-paths)
|
||||
new-paths)))
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
:app-db/expansions
|
||||
:<- [:app-db/root]
|
||||
(fn [app-db-settings _]
|
||||
(get app-db-settings :json-ml-paths)))
|
||||
(get app-db-settings :json-ml-expansions)))
|
||||
|
||||
(rf/reg-sub
|
||||
:app-db/node-expanded?
|
||||
|
|
Loading…
Reference in New Issue