Show spinner when repos are loading

This commit is contained in:
Teemu Patja 2017-01-30 21:06:17 +02:00
parent da7107ce87
commit fb136e656d
No known key found for this signature in database
GPG Key ID: F5B7035E6580FD4C
4 changed files with 15 additions and 4 deletions

View File

@ -4,6 +4,7 @@
{:page :issues
:user nil
:user-profile nil
:repos-loading? false
:repos []
:enabled-repos {}
:all-bounties []

View File

@ -111,12 +111,14 @@
(reg-event-db
:set-user-repos
(fn [db [_ repos]]
(assoc db :repos repos)))
(-> db
(assoc :repos repos)
(assoc :repos-loading? false))))
(reg-event-fx
:load-user-repos
(fn [{:keys [db]} [_]]
{:db db
{:db (assoc db :repos-loading? true)
:http {:method GET
:url "/api/user/repositories"
:on-success #(dispatch [:set-user-repos (:repositories %)])}}))

View File

@ -22,10 +22,13 @@
[:p.text-gray.mt-1 description]]]]))
(defn repos-list []
(let [repos (rf/subscribe [:repos])]
(let [repos-loading? (rf/subscribe [:repos-loading?])
repos (rf/subscribe [:repos])]
(fn []
[:div
(map repository-row @repos)])))
(if @repos-loading?
[:i.fa.fa-spinner.fa-spin]
(map repository-row @repos))])))
(defn enable-disable-button
[button-id disable]

View File

@ -11,6 +11,11 @@
(fn [db _]
(:user db)))
(reg-sub
:repos-loading?
(fn [db _]
(:repos-loading? db)))
(reg-sub
:repos
(fn [db _]