Skip to content

Commit

Permalink
Refactor: extract function
Browse files Browse the repository at this point in the history
  • Loading branch information
ilmotta committed Nov 9, 2023
1 parent 0033a34 commit c259260
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
4 changes: 4 additions & 0 deletions src/schema/state.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
"Set of schema identifiers, usually namespaced keywords. When the set is empty,
no schema errors will be displayed on the app. See `schema.view/view`."
(reagent/atom #{}))

(defn clear-errors
[]
(reset! errors #{}))
18 changes: 8 additions & 10 deletions src/schema/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@

(defn view
[]
(let [on-press #(reset! schema.state/errors #{})]
(fn []
(when (seq @schema.state/errors)
[rn/pressable
{:on-press on-press
:style (style/container {:bottom-inset (safe-area/get-bottom)})}
[quo/icon :i/close {:size 12 :color "#ddd" :container-style style/icon}]
[rn/text {:style style/text}
"Schema error(s)"
[rn/text {:style (merge style/text style/text-suffix)} " check logs"]]]))))
(when (seq @schema.state/errors)
[rn/pressable
{:on-press schema.state/clear-errors
:style (style/container {:bottom-inset (safe-area/get-bottom)})}
[quo/icon :i/close {:size 12 :color "#ddd" :container-style style/icon}]
[rn/text {:style style/text}
"Schema error(s)"
[rn/text {:style (merge style/text style/text-suffix)} " check logs"]]]))
2 changes: 1 addition & 1 deletion src/status_im2/setup/hot_reload.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
(reset! label "reloading UI")
(re-frame/clear-subscription-cache!)
(schema/setup!)
(reset! schema.state/errors #{})
(schema.state/clear-errors)
(swap! cnt inc))

(defn before-reload
Expand Down

0 comments on commit c259260

Please sign in to comment.