mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-07 10:43:39 +02:00
Use more sensible naming for api responses
This commit is contained in:
parent
bebd674d7c
commit
02f558226c
4 changed files with 16 additions and 16 deletions
|
|
@ -15,13 +15,13 @@
|
|||
{:http-xhrio {:method :get
|
||||
:uri (api/url (:credentials db) endpoint params)
|
||||
:response-format (ajax/json-response-format {:keywords? true})
|
||||
:on-success [:api/good-response endpoint params]
|
||||
:on-failure [:api/failed-response endpoint params]}
|
||||
:on-success [:api.response/ok endpoint params]
|
||||
:on-failure [:api.response/failed endpoint params]}
|
||||
:db (assoc-in db (conj (cache-path endpoint params) :api/is-loading?) true)})
|
||||
|
||||
(reg-event-fx :api/request api-request)
|
||||
|
||||
(defn good-api-response
|
||||
(defn api-success
|
||||
"Handles when the server responded. There could still be an error while
|
||||
processing the request on the server side which we have to account for."
|
||||
[{:keys [db]} [_ endpoint params response]]
|
||||
|
|
@ -32,9 +32,9 @@
|
|||
{:dispatch [:notification/show :error (api/error-msg e)]
|
||||
:db (update-in db response-cache dissoc :api/is-loading?)}))))
|
||||
|
||||
(reg-event-fx :api/good-response good-api-response)
|
||||
(reg-event-fx :api.response/ok api-success)
|
||||
|
||||
(defn failed-api-response
|
||||
(defn api-failure
|
||||
"Handler for catastrophic failures (network errors and such things)"
|
||||
[fx [ev endpoint params]]
|
||||
(let [response-cache (cons :db (cache-path endpoint params))]
|
||||
|
|
@ -42,4 +42,4 @@
|
|||
:dispatch [:notification/show :error "Communication with server failed. Check browser logs for details."]
|
||||
:db (update-in fx response-cache dissoc :api/is-loading?)}))
|
||||
|
||||
(reg-event-fx :api/failed-response failed-api-response)
|
||||
(reg-event-fx :api.response/failed api-failure)
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@
|
|||
:uri (api/url credentials "getUser" {:username (:u credentials)})
|
||||
:response-format (ajax/json-response-format {:keywords? true})
|
||||
:on-success [:credentials/authentication-response credentials]
|
||||
:on-failure [:api/failed-response]}}) ; <- we don't need endpoint and params here because the response is not cached
|
||||
:on-failure [:api.response/failed]}}) ; <- we don't need endpoint and params here because the response is not cached
|
||||
|
||||
(rf/reg-event-fx :credentials/send-authentication-request authentication-request)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue