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])))
(reset! active-user nil)))
(defn load-data []
(defn load-data [initial-load?]
(doall (map rf/dispatch
[[:load-open-bounties]
[:load-activity-feed]
[:load-top-hunters]]))
[[:load-open-bounties initial-load?]
[:load-activity-feed initial-load?]
[:load-top-hunters initial-load?]]))
(load-user))
(defonce timer-id (r/atom nil))
@ -273,7 +273,7 @@
(defn on-js-load []
(when-not (nil? @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))
(defn init! []
@ -283,5 +283,5 @@
(enable-re-frisk!))
(load-interceptors!)
(hook-browser-navigation!)
(load-data)
(load-data true)
(on-js-load))

View File

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