瀏覽代碼

fix: Contents removed when switching graph

fixes https://github.com/logseq/db-test/issues/94
Tienson Qin 1 年之前
父節點
當前提交
6a06911fee

+ 1 - 1
src/main/frontend/components/container.cljs

@@ -606,7 +606,7 @@
                  (doseq [page pages]
                    (let [page (util/safe-page-name-sanity-lc page)
                          [db-id block-type] (if (= page "contents")
-                                              ["contents" :contents]
+                                              [(or (:db/id (db/get-page page)) "contents") :contents]
                                               [(:db/id (db/get-page page)) :page])]
                      (state/sidebar-add-block! current-repo db-id block-type)))
                  (reset! sidebar-inited? true))))

+ 6 - 11
src/main/frontend/components/page.cljs

@@ -679,17 +679,12 @@
   [state option]
   (rum/with-key
     (page-aux option)
-    (or (:page-name option)
-      (get-page-name state))))
-
-(rum/defc contents-page < rum/reactive
-                          {:init (fn [state]
-                                   (db-async/<get-block (state/get-current-repo) "contents")
-                                   state)}
-  [page]
-  (when-let [repo (state/get-current-repo)]
-    (when-not (state/sub-async-query-loading "contents")
-      (page-blocks-cp repo page {:sidebar? true}))))
+    (str
+     (state/get-current-repo)
+     "-"
+     (or (:page-name option)
+         (get-page-name state)))))
+
 
 (defonce layout (atom [js/window.innerWidth js/window.innerHeight]))
 

+ 3 - 9
src/main/frontend/components/right_sidebar.cljs

@@ -45,14 +45,8 @@
 (rum/defc page-cp < rum/reactive
   [repo page-name]
   (page/page-cp {:parameters {:path {:name page-name}}
-              :sidebar?   true
-              :repo       repo}))
-
-(rum/defc contents < rum/reactive db-mixins/query
-  []
-  [:div.contents.flex-col.flex.ml-3
-   (when-let [contents-page (db/get-page "contents")]
-     (page/contents-page contents-page))])
+                 :sidebar?   true
+                 :repo       repo}))
 
 (rum/defc shortcut-settings
   []
@@ -74,7 +68,7 @@
   (case (keyword block-type)
     :contents
     [[:.flex.items-center (ui/icon "list-details" {:class "text-md mr-2"}) (t :right-side-bar/contents)]
-     (contents)]
+     (page-cp repo "contents")]
 
     :help
     [[:.flex.items-center (ui/icon "help" {:class "text-md mr-2"}) (t :right-side-bar/help)] (onboarding/help)]