Smoother background fetching of data

* do not show loading spinner after periodic open bounty and activity
  data  fetches
This commit is contained in:
Teemu Patja 2017-10-31 22:09:31 +02:00
parent b0db973fa6
commit 6dd88874f6
No known key found for this signature in database
GPG Key ID: F5B7035E6580FD4C
2 changed files with 14 additions and 10 deletions

View File

@ -261,11 +261,11 @@
js/adminToken]))) js/adminToken])))
(reset! active-user nil))) (reset! active-user nil)))
(defn load-data [] (defn load-data [initial-load?]
(doall (map rf/dispatch (doall (map rf/dispatch
[[:load-open-bounties] [[:load-open-bounties initial-load?]
[:load-activity-feed] [:load-activity-feed initial-load?]
[:load-top-hunters]])) [:load-top-hunters initial-load?]]))
(load-user)) (load-user))
(defonce timer-id (r/atom nil)) (defonce timer-id (r/atom nil))
@ -273,7 +273,7 @@
(defn on-js-load [] (defn on-js-load []
(when-not (nil? @timer-id) (when-not (nil? @timer-id)
(js/clearInterval @timer-id)) (js/clearInterval @timer-id))
(reset! timer-id (js/setInterval load-data 60000)) (reset! timer-id (js/setInterval #(load-data false) 60000))
(mount-components)) (mount-components))
(defn init! [] (defn init! []
@ -283,5 +283,5 @@
(enable-re-frisk!)) (enable-re-frisk!))
(load-interceptors!) (load-interceptors!)
(hook-browser-navigation!) (hook-browser-navigation!)
(load-data) (load-data true)
(on-js-load)) (on-js-load))

View File

@ -145,8 +145,10 @@
(reg-event-fx (reg-event-fx
:load-activity-feed :load-activity-feed
(fn [{:keys [db]} [_]] (fn [{:keys [db]} [_ initial-load?]]
{:db (assoc db :activity-feed-loading? true) {:db (if initial-load?
(assoc db :activity-feed-loading? true)
db)
:http {:method GET :http {:method GET
:url "/api/activity-feed" :url "/api/activity-feed"
:on-success #(dispatch [:set-activity-feed %])}})) :on-success #(dispatch [:set-activity-feed %])}}))
@ -161,8 +163,10 @@
(reg-event-fx (reg-event-fx
:load-open-bounties :load-open-bounties
(fn [{:keys [db]} [_]] (fn [{:keys [db]} [_ initial-load?]]
{:db (assoc db :open-bounties-loading? true) {:db (if initial-load?
(assoc db :open-bounties-loading? true)
db)
:http {:method GET :http {:method GET
:url "/api/open-bounties" :url "/api/open-bounties"
:on-success #(dispatch [:set-open-bounties %])}})) :on-success #(dispatch [:set-open-bounties %])}}))