From f76597ab7bb4dc00ff8cd101b37a2d9aa69dc6e2 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Thu, 9 Jul 2020 18:27:43 +0800 Subject: [PATCH] Loading --- web/src/main/frontend/components/sidebar.cljs | 22 ++++++++++++------- .../main/frontend/extensions/graph_2d.cljs | 8 +++---- web/src/main/frontend/extensions/slide.cljs | 2 +- web/src/main/frontend/handler.cljs | 2 +- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/web/src/main/frontend/components/sidebar.cljs b/web/src/main/frontend/components/sidebar.cljs index d71b22af80..1058fcbcbc 100644 --- a/web/src/main/frontend/components/sidebar.cljs +++ b/web/src/main/frontend/components/sidebar.cljs @@ -89,13 +89,9 @@ latest-journals (db/get-latest-journals (state/get-current-repo) journals-length) preferred-format (state/sub [:me :preferred_format]) logged? (:name me) - token (state/sub :encrypt/token) - db-restoring? (state/sub :db/restoring?)] + token (state/sub :encrypt/token)] [:div.max-w-7xl.mx-auto (cond - db-restoring? - (widgets/loading "Loading") - (and (not logged?) (seq latest-journals)) (journal/journals latest-journals) @@ -160,7 +156,8 @@ theme (state/sub :ui/theme) white? (= "white" (state/sub :ui/theme)) global-graph-pages? (= :graph (get-in route-match [:data :name])) - logged? (:name me)] + logged? (:name me) + db-restoring? (state/sub :db/restoring?)] [:div {:class (if white? "white-theme" "dark-theme") :on-click (fn [] (handler/unhighlight-heading!))} @@ -294,9 +291,18 @@ {:position "relative" :max-width 700 :margin-bottom 200})} - (if global-graph-pages? + (cond + db-restoring? + [:div.mt-20 + [:div.ls-center + (widgets/loading "Loading")]] + + global-graph-pages? main-content - [:div.m-6 main-content])]]] + + :else + [:div.m-6 + main-content])]]] (right-sidebar/sidebar)] [:a.opacity-70.hover:opacity-100.absolute.hidden.md:block {:title "Logseq" diff --git a/web/src/main/frontend/extensions/graph_2d.cljs b/web/src/main/frontend/extensions/graph_2d.cljs index ea06fce677..c849928b2d 100644 --- a/web/src/main/frontend/extensions/graph_2d.cljs +++ b/web/src/main/frontend/extensions/graph_2d.cljs @@ -30,8 +30,6 @@ state)} [opts] (let [loading? (rum/react *loading?)] - (if loading? - (widgets/loading "Loading") - (when @graph-component - (@graph-component - opts))))) + (when @graph-component + (@graph-component + opts)))) diff --git a/web/src/main/frontend/extensions/slide.cljs b/web/src/main/frontend/extensions/slide.cljs index 34fd52564c..ebbe11fbaf 100644 --- a/web/src/main/frontend/extensions/slide.cljs +++ b/web/src/main/frontend/extensions/slide.cljs @@ -53,7 +53,7 @@ (let [loading? (rum/react *loading?)] [:div.reveal {:style {:height 400}} (when loading? - (widgets/loading "Loading")) + [:div.ls-center (widgets/loading "")]) [:div.slides (for [[idx sections] (medley/indexed sections)] (if (> (count sections) 1) ; nested diff --git a/web/src/main/frontend/handler.cljs b/web/src/main/frontend/handler.cljs index 7eea5e2db8..d62764ecda 100644 --- a/web/src/main/frontend/handler.cljs +++ b/web/src/main/frontend/handler.cljs @@ -1340,10 +1340,10 @@ [{:url config/local-repo}])] (when me (set-state-kv! :me me)) (state/set-db-restoring! true) + (render) (-> (p/all (db/restore! (assoc me :repos repos) db-listen-to-tx! restore-config!)) (p/then (fn [] - (render) (if (and (not logged?) (not (seq (db/get-files config/local-repo)))) (setup-local-repo-if-not-exists!)