Only request user repos when admin token available

This commit is contained in:
Teemu Patja 2017-04-12 15:28:16 +03:00
parent d6aaa2dcea
commit 2a05a6bef7
No known key found for this signature in database
GPG Key ID: F5B7035E6580FD4C
1 changed files with 9 additions and 8 deletions

View File

@ -213,14 +213,15 @@
(reg-event-fx (reg-event-fx
:load-user-repos :load-user-repos
(fn [{:keys [db]} [_]] (fn [{:keys [db]} [_]]
{:db (assoc db :repos-loading? true) (conj {:db (assoc db :repos-loading? true)}
(when-let [token (get-admin-token db)]
:http {:method GET :http {:method GET
:url "/api/user/repositories" :url "/api/user/repositories"
:params {:token (get-admin-token db)} :params {:token token}
:on-success #(dispatch [:set-user-repos (:repositories %)]) :on-success #(dispatch [:set-user-repos (:repositories %)])
:on-error #(dispatch [:set-flash-message :on-error #(dispatch [:set-flash-message
:error "Failed to load repositories"]) :error "Failed to load repositories"])
:finally #(dispatch [:clear-repos-loading])}})) :finally #(dispatch [:clear-repos-loading])}))))
(defn update-repo-state [all-repos full-name data] (defn update-repo-state [all-repos full-name data]