Просмотр исходного кода

chore: remove unused fns and move file graph fn

Gabriel Horner 1 год назад
Родитель
Сommit
de89e65129

+ 0 - 8
.carve/ignore

@@ -37,21 +37,13 @@ frontend.fs/readdir
 ;; Referenced in TODO
 frontend.handler.metadata/update-properties!
 ;; Referenced in comment
-frontend.handler.route/toggle-between-page-and-file!
-;; Referenced in comment
-frontend.handler.shell/run-pandoc-command!
-;; Referenced in comment
 frontend.image/get-orientation
 ;; For debugging
 frontend.mixins/perf-measure-mixin
 ;; Previously useful fn
 frontend.mobile.util/get-idevice-statusbar-height
-;; Referenced in comment
-frontend.page/route-view
 ;; placeholder fn
 frontend.publishing/stop
-;; Referenced in comment
-frontend.state/set-db-persisted!
 ;; Future use
 frontend.storage/get-transit
 ;; repl fn

+ 0 - 12
deps/db/src/logseq/db.cljs

@@ -159,12 +159,6 @@
   [db id]
   (d/pull db '[*] id))
 
-(def get-by-parent-id
-  '[:find (pull ?a [*])
-    :in $ ?id
-    :where
-    [?a :block/parent ?id]])
-
 (defn hidden-page?
   [page]
   (when page
@@ -425,12 +419,6 @@
     (when (seq pages)
       (first pages))))
 
-(defn get-page-file
-  [db page-name]
-  (some-> (or (d/entity db [:block/name page-name])
-              (d/entity db [:block/original-name page-name]))
-          :block/file))
-
 (defn get-namespace-pages
   "Accepts both sanitized and unsanitized namespaces"
   [db namespace {:keys [db-graph?]}]

+ 7 - 1
deps/graph-parser/src/logseq/graph_parser/db.cljs

@@ -52,4 +52,10 @@
   []
   (let [db-conn (d/create-conn db-schema/schema)]
     (create-default-pages! db-conn)
-    db-conn))
+    db-conn))
+
+(defn get-page-file
+  [db page-name]
+  (some-> (or (d/entity db [:block/name page-name])
+              (d/entity db [:block/original-name page-name]))
+          :block/file))

+ 1 - 1
src/main/frontend/db/model.cljs

@@ -529,7 +529,7 @@ independent of format as format specific heading characters are stripped"
    (get-page-file (state/get-current-repo) page-name))
   ([repo page-name]
    (when-let [db (conn/get-db repo)]
-     (ldb/get-page-file db page-name))))
+     (gp-db/get-page-file db page-name))))
 
 (defn get-block-file-path
   [block]

+ 2 - 33
src/main/frontend/handler/route.cljs

@@ -1,7 +1,6 @@
 (ns frontend.handler.route
   "Provides fns used for routing throughout the app"
-  (:require [clojure.string :as string]
-            [frontend.config :as config]
+  (:require [frontend.config :as config]
             [frontend.date :as date]
             [frontend.db :as db]
             [frontend.db.model :as model]
@@ -211,34 +210,4 @@
                 :all-journals
                 :home)]
     (redirect! {:to route}))
-  (util/scroll-to-top))
-
-(defn- redirect-to-file!
-  [page]
-  (when-let [path (-> (db/get-page-file (string/lower-case page))
-                      :db/id
-                      (db/entity)
-                      :file/path)]
-    (redirect! {:to :file
-                :path-params {:path path}})))
-
-(defn toggle-between-page-and-file!
-  [_e]
-  (let [current-route (state/get-current-route)]
-    (case current-route
-      :home
-      (redirect-to-file! (date/today))
-
-      :all-journals
-      (redirect-to-file! (date/today))
-
-      :page
-      (when-let [page-name (get-in (state/get-route-match) [:path-params :name])]
-        (redirect-to-file! page-name))
-
-      :file
-      (when-let [path (get-in (state/get-route-match) [:path-params :path])]
-        (when-let [page (db/get-file-page path)]
-          (redirect-to-page! page)))
-
-      nil)))
+  (util/scroll-to-top))

+ 0 - 4
src/main/frontend/page.cljs

@@ -12,10 +12,6 @@
             [frontend.components.plugins :as plugin]
             [frontend.context.i18n :refer [t]]))
 
-(rum/defc route-view
-  [view route-match]
-  (view route-match))
-
 (defn- setup-fns!
   []
   (try

+ 2 - 1
src/main/frontend/worker/handler/page.cljs

@@ -1,6 +1,7 @@
 (ns frontend.worker.handler.page
   "Page operations"
   (:require [logseq.db :as ldb]
+            [logseq.graph-parser.db :as gp-db]
             [logseq.graph-parser.block :as gp-block]
             [logseq.graph-parser.property :as gp-property]
             [logseq.db.sqlite.util :as sqlite-util]
@@ -221,7 +222,7 @@
                            {:outliner-op :truncate-page-blocks :persist-op? persist-op?})
             (error-handler msg)
             false)
-          (let [file (ldb/get-page-file @conn page-name)
+          (let [file (gp-db/get-page-file @conn page-name)
                 file-path (:file/path file)
                 delete-file-tx (when file
                                  [[:db.fn/retractEntity [:file/path file-path]]])