Add :user-profile-loaded? event/sub

This commit is contained in:
Vitaliy Vlasov 2018-02-08 18:08:44 +02:00
parent 8a75d5d68c
commit 8b0622480d
4 changed files with 17 additions and 3 deletions

View File

@ -3,6 +3,7 @@
(def default-db (def default-db
{:page :bounties {:page :bounties
:user nil :user nil
:user-profile-loaded? false
:repos-loading? false :repos-loading? false
:repos {} :repos {}
:activity-feed-loading? false :activity-feed-loading? false

View File

@ -222,7 +222,8 @@
:set-user-profile :set-user-profile
(fn [{:keys [db]} [_ user-profile]] (fn [{:keys [db]} [_ user-profile]]
{:db {:db
(assoc db :user (:user user-profile)) (assoc db :user (:user user-profile)
:user-profile-loaded? true)
:dispatch-n [[:load-user-repos] :dispatch-n [[:load-user-repos]
[:load-owner-bounties]]})) [:load-owner-bounties]]}))

View File

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

View File

@ -6,8 +6,7 @@
[clojure.string :as str] [clojure.string :as str]
[cljs-web3.eth :as web3-eth])) [cljs-web3.eth :as web3-eth]))
(defn update-address-page-contents []
(defn update-address-page []
(let [db (rf/subscribe [:db]) (let [db (rf/subscribe [:db])
user (rf/subscribe [:user]) user (rf/subscribe [:user])
updating-address (rf/subscribe [:get-in [:updating-address]]) updating-address (rf/subscribe [:get-in [:updating-address]])
@ -55,3 +54,11 @@
(when @updating-address (when @updating-address
" busy loading"))}) " busy loading"))})
"UPDATE"]]])))) "UPDATE"]]]))))
(defn update-address-page []
(let [loaded? @(rf/subscribe [:user-profile-loaded?])]
(if loaded?
[update-address-page-contents]
[:div.view-loading-container
[:div.ui.active.inverted.dimmer
[:div.ui.text.loader.view-loading-label "Loading"]]])))