Skip to content

Commit

Permalink
added more exception handling to stringification
Browse files Browse the repository at this point in the history
  • Loading branch information
awkay committed May 30, 2020
1 parent 1fc469b commit e38a595
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion shells/chrome/manifest.edn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{:manifest_version 2
:name "Fulcro Inspect"
:version "1.0.20"
:version "1.0.21"
:description "Fulcro is a development framework that uses React and CLJS. This extension adds ability to track Fulcro DB, transactions and network"

:icons {"16" "icon-16.png"
Expand Down
55 changes: 29 additions & 26 deletions src/client/fulcro/inspect/helpers.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

(defn- om-ident? [x]
(and (vector? x)
(= 2 (count x))
(keyword? (first x))))
(= 2 (count x))
(keyword? (first x))))

(defn query-component
([this]
Expand All @@ -26,7 +26,7 @@
state (-> this fp/get-reconciler fp/app-state deref)
query (fp/focus-query (fp/get-query component) focus-path)]
(-> (fp/db->tree query (get-in state ref) state)
(get-in focus-path)))))
(get-in focus-path)))))

(defn swap-entity! [{:keys [state ref]} & args]
(apply swap! state update-in ref args))
Expand Down Expand Up @@ -103,7 +103,7 @@
fp/IQuery
(query [_] [{::root (fp/get-query x)}]))
{::root data} true)
(dissoc ::root ::fp/tables))
(dissoc ::root ::fp/tables))
root-ident (fp/ident x data)
state (merge-with (partial merge-with merge) state idents)]
(if (seq named-parameters)
Expand All @@ -112,13 +112,13 @@

(defn named-params-with-ref [ref named-parameters]
(->> (partition 2 named-parameters)
(map (fn [[op path]] [op (conj ref path)]))
(apply concat)))
(map (fn [[op path]] [op (conj ref path)]))
(apply concat)))

(defn create-entity! [{:keys [state ref]} x data & named-parameters]
(let [named-parameters (->> (partition 2 named-parameters)
(map (fn [[op path]] [op (conj ref path)]))
(apply concat))
(map (fn [[op path]] [op (conj ref path)]))
(apply concat))
data' (if (-> data meta ::initialized)
data
(fp/get-initial-state x data))]
Expand All @@ -138,16 +138,16 @@
"Remove a ref and all linked refs from it."
(let [item (get-in state ref)
idents (into []
(comp (keep (fn [v]
(cond
(om-ident? v)
[v]

(and (vector? v)
(every? om-ident? v))
v)))
cat)
(vals item))]
(comp (keep (fn [v]
(cond
(om-ident? v)
[v]

(and (vector? v)
(every? om-ident? v))
v)))
cat)
(vals item))]
(reduce
(fn [s i] (deep-remove-ref s i))
(dissoc-in state ref)
Expand All @@ -158,17 +158,17 @@
(cond
(om-ident? children)
(swap! state (comp #(update-in % ref dissoc field)
#(deep-remove-ref % children)))
#(deep-remove-ref % children)))

(seq children)
(swap! state (comp #(assoc-in % (conj ref field) [])
#(reduce deep-remove-ref % children))))))
#(reduce deep-remove-ref % children))))))

(defn vec-remove-index [i v]
"Remove an item from a vector via index."
(->> (concat (subvec v 0 i)
(subvec v (inc i) (count v)))
(vec)))
(subvec v (inc i) (count v)))
(vec)))

(mutations/defmutation persistent-set-props [{::keys [local-key storage-key value]}]
(action [env]
Expand All @@ -192,7 +192,7 @@
"Extracts the app uuid from a ident."
[ref]
(assert (and (vector? ref)
(vector? (second ref)))
(vector? (second ref)))
"Ref with app it must be in the format: [:id-key [::app-id app-id]]")
(let [[_ [_ app-id]] ref]
app-id))
Expand Down Expand Up @@ -223,8 +223,8 @@

(defn matching-apps [state app-id]
(->> (all-apps state)
(filterv #(= app-id (:fulcro.inspect.core/app-id (get-in state %))))
(mapv second)))
(filterv #(= app-id (:fulcro.inspect.core/app-id (get-in state %))))
(mapv second)))

(defn update-matching-apps [state app-id f]
(let [apps (matching-apps state app-id)]
Expand All @@ -245,7 +245,10 @@
#_=> (str "#transit/bigdec " \" (.-rep x) \")
(tempid/tempid? x)
#_=> (str "#fulcro/tempid " \" (.-id x) \")
:else (pr-str x)))
:else (try
(pr-str x)
(catch :default e
"UNSUPPORTED VALUE"))))

(extend-protocol IPrintWithWriter
transit.types/TaggedValue
Expand Down

0 comments on commit e38a595

Please sign in to comment.