Transactions are converted!
This commit is contained in:
@@ -89,6 +89,12 @@
|
||||
(assoc db single {:state :loading
|
||||
:error nil})))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::dispose-single
|
||||
[(re-frame/path [::status]) ]
|
||||
(fn [db [_ single]]
|
||||
(dissoc db single )))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::completed
|
||||
[(re-frame/path [::status]) ]
|
||||
@@ -101,17 +107,33 @@
|
||||
[(re-frame/path [::status]) ]
|
||||
(fn [db [_ single error]]
|
||||
(assoc db single {:state :error
|
||||
:info nil
|
||||
:error error})))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::info
|
||||
[(re-frame/path [::status]) ]
|
||||
(fn [db [_ single info]]
|
||||
(assoc db single {:info info})))
|
||||
|
||||
(defn status-notification [{:keys [statuses]}]
|
||||
(let [states
|
||||
(->> statuses
|
||||
(mapv #(deref (re-frame/subscribe %)))
|
||||
(filter #(= :error (:state %))))]
|
||||
(when (seq states)
|
||||
[:div.notification.is-warning
|
||||
(for [state states
|
||||
state (:error state)]
|
||||
(do
|
||||
^{:key (:message state)}
|
||||
[:p (:message state)]))])))
|
||||
(let [states (mapv #(deref (re-frame/subscribe %)) statuses)
|
||||
error-states
|
||||
(->> states
|
||||
(filter #(= :error (:state %))))
|
||||
info-states
|
||||
(->> states (filter #(:info %)))]
|
||||
[:<>
|
||||
(if (seq error-states)
|
||||
[:div.notification.is-warning
|
||||
(for [state states
|
||||
state (:error state)]
|
||||
(do
|
||||
^{:key (:message state)}
|
||||
[:p (:message state)]))])
|
||||
(if (seq info-states)
|
||||
[:div.notification
|
||||
(for [state states]
|
||||
(do
|
||||
^{:key (:info state)}
|
||||
[:p (:info state)]))])]))
|
||||
|
||||
Reference in New Issue
Block a user