Explorar o código

chore: mv handler ns to file-based

since it's only used by file graphs. Also remove unnecessary
db-based-graph? calls in in ns and make aliasing consistent for this ns
Gabriel Horner hai 10 meses
pai
achega
8710195440

+ 1 - 0
.clj-kondo/config.edn

@@ -108,6 +108,7 @@
              frontend.handler.editor.property editor-property
              frontend.handler.events events
              frontend.handler.extract extract
+             frontend.handler.file-based.file file-handler
              frontend.handler.file-based.page file-page-handler
              frontend.handler.file-based.page-property file-page-property
              frontend.handler.file-based.property file-property-handler

+ 3 - 3
src/main/frontend/components/diff.cljs

@@ -1,7 +1,7 @@
 (ns frontend.components.diff
   (:require [clojure.string :as string]
             [frontend.diff :as diff]
-            [frontend.handler.file :as file]
+            [frontend.handler.file-based.file :as file-handler]
             [frontend.ui :as ui]
             [frontend.util :as util]
             [logseq.shui.ui :as shui]
@@ -70,7 +70,7 @@
                  :on-click
                  (fn []
                    (when-let [value @disk-value]
-                     (file/alter-file repo path value
+                     (file-handler/alter-file repo path value
                                       {:re-render-root? true
                                        :skip-compare? true}))
                    (shui/dialog-close!)))]
@@ -87,7 +87,7 @@
                  :on-click
                  (fn []
                    (when-let [value @db-value]
-                     (file/alter-file repo path value
+                     (file-handler/alter-file repo path value
                                       {:re-render-root? true
                                        :skip-compare? true}))
                    (shui/dialog-close!)))]]]])

+ 2 - 2
src/main/frontend/components/git.cljs

@@ -1,6 +1,6 @@
 (ns frontend.components.git
   (:require [clojure.string :as string]
-            [frontend.handler.file :as file]
+            [frontend.handler.file-based.file :as file-handler]
             [frontend.handler.shell :as shell]
             [frontend.hooks :as hooks]
             [frontend.state :as state]
@@ -72,7 +72,7 @@
        [:pre content]
        (ui/button "Revert"
                   :on-click (fn []
-                              (file/alter-file (state/get-current-repo)
+                              (file-handler/alter-file (state/get-current-repo)
                                                path
                                                content
                                                {:re-render-root? true

+ 1 - 1
src/main/frontend/fs/sync.cljs

@@ -25,7 +25,7 @@
             [frontend.fs :as fs]
             [frontend.fs.capacitor-fs :as capacitor-fs]
             [frontend.fs.diff-merge :as diff-merge]
-            [frontend.handler.file :as file-handler]
+            [frontend.handler.file-based.file :as file-handler]
             [frontend.handler.notification :as notification]
             [frontend.handler.user :as user]
             [frontend.mobile.util :as mobile-util]

+ 1 - 1
src/main/frontend/fs/watcher_handler.cljs

@@ -7,7 +7,7 @@
             [frontend.db.model :as model]
             [frontend.fs :as fs]
             [logseq.common.path :as path]
-            [frontend.handler.file :as file-handler]
+            [frontend.handler.file-based.file :as file-handler]
             [frontend.handler.file-based.property :as file-property-handler]
             [frontend.handler.global-config :as global-config-handler]
             [frontend.handler.notification :as notification]

+ 3 - 2
src/main/frontend/handler.cljs

@@ -16,7 +16,7 @@
             [frontend.error :as error]
             [frontend.handler.command-palette :as command-palette]
             [frontend.handler.events :as events]
-            [frontend.handler.file :as file-handler]
+            [frontend.handler.file-based.file :as file-handler]
             [frontend.handler.file-based.events]
             [frontend.handler.global-config :as global-config-handler]
             [frontend.handler.notification :as notification]
@@ -95,7 +95,8 @@
            (page-handler/init-commands!)
 
            (watch-for-date!)
-           (when (util/electron?) (file-handler/watch-for-current-graph-dir!))))
+           (when (and (not (config/db-based-graph? repo)) (util/electron?))
+             (file-handler/watch-for-current-graph-dir!))))
         (p/catch (fn [error]
                    (log/error :exception error))))))
 

+ 1 - 1
src/main/frontend/handler/code.cljs

@@ -4,7 +4,7 @@
             [frontend.config :as config]
             [frontend.db :as db]
             [frontend.handler.editor :as editor-handler]
-            [frontend.handler.file :as file-handler]
+            [frontend.handler.file-based.file :as file-handler]
             [frontend.state :as state]
             [goog.object :as gobj]
             [logseq.graph-parser.utf8 :as utf8]

+ 1 - 1
src/main/frontend/handler/config.cljs

@@ -5,7 +5,7 @@
             [frontend.config :as config]
             [frontend.db :as db]
             [frontend.handler.db-based.editor :as db-editor-handler]
-            [frontend.handler.file :as file-handler]
+            [frontend.handler.file-based.file :as file-handler]
             [frontend.handler.repo-config :as repo-config-handler]
             [frontend.state :as state]))
 

+ 1 - 1
src/main/frontend/handler/draw.cljs

@@ -5,7 +5,7 @@
             [frontend.date :as date]
             [frontend.db :as db]
             [frontend.fs :as fs]
-            [frontend.handler.file :as file-handler]
+            [frontend.handler.file-based.file :as file-handler]
             [frontend.state :as state]
             [frontend.util :as util]
             [logseq.common.config :as common-config]

+ 1 - 1
src/main/frontend/handler/events.cljs

@@ -46,7 +46,7 @@
             [frontend.handler.db-based.rtc :as rtc-handler]
             [frontend.handler.editor :as editor-handler]
             [frontend.handler.export :as export]
-            [frontend.handler.file :as file-handler]
+            [frontend.handler.file-based.file :as file-handler]
             [frontend.handler.file-based.nfs :as nfs-handler]
             [frontend.handler.file-sync :as file-sync-handler]
             [frontend.handler.graph :as graph-handler]

+ 6 - 6
src/main/frontend/handler/file.cljs → src/main/frontend/handler/file_based/file.cljs

@@ -1,5 +1,5 @@
-(ns frontend.handler.file
-  "Provides util handler fns for files"
+(ns frontend.handler.file-based.file
+  "Provides util handler fns for file graph files"
   (:refer-clojure :exclude [load-file])
   (:require [frontend.config :as config]
             [frontend.db :as db]
@@ -35,7 +35,7 @@
          (println "Load file failed: " path)
          (js/console.error e)))))
 
-(defn load-multiple-files
+(defn- load-multiple-files
   [repo-url paths]
   (doall
    (mapv #(load-file repo-url %) paths)))
@@ -92,7 +92,7 @@
   [path content]
   (when (or (= path "logseq/config.edn")
             (= (path/dirname path) (global-config-handler/safe-global-config-dir)))
-    (config-edn-common-handler/detect-deprecations path content {:db-graph? (config/db-based-graph? (state/get-current-repo))})))
+    (config-edn-common-handler/detect-deprecations path content {:db-graph? false})))
 
 (defn- validate-file
   "Returns true if valid and if false validator displays error message. Files
@@ -202,7 +202,7 @@
   (alter-file repo path new-content {:reset? false
                                      :re-render-root? false}))
 
-(defn alter-files-handler!
+(defn- alter-files-handler!
   [repo files {:keys [finish-handler]} file->content]
   (let [write-file-f (fn [[path content]]
                        (when path
@@ -255,7 +255,7 @@
 (defn watch-for-current-graph-dir!
   []
   (when-let [repo (state/get-current-repo)]
-    (when-let [dir (and (not (config/db-based-graph? repo)) (config/get-repo-dir repo))]
+    (when-let [dir (config/get-repo-dir repo)]
       ;; An unwatch shouldn't be needed on startup. However not having this
       ;; after an app refresh can cause stale page data to load
       (fs/unwatch-dir! dir)

+ 1 - 1
src/main/frontend/handler/file_based/repo.cljs

@@ -3,7 +3,7 @@
   (:require [frontend.config :as config]
             [frontend.db :as db]
             [frontend.fs :as fs]
-            [frontend.handler.file :as file-handler]
+            [frontend.handler.file-based.file :as file-handler]
             [frontend.handler.repo-config :as repo-config-handler]
             [frontend.handler.common.file :as file-common-handler]
             [frontend.handler.route :as route-handler]

+ 1 - 1
src/main/frontend/handler/import.cljs

@@ -13,7 +13,7 @@
             [frontend.format.block :as block]
             [frontend.format.mldoc :as mldoc]
             [frontend.handler.editor :as editor]
-            [frontend.handler.file :as file-handler]
+            [frontend.handler.file-based.file :as file-handler]
             [frontend.handler.file-based.repo :as file-repo-handler]
             [frontend.handler.notification :as notification]
             [frontend.handler.page :as page-handler]

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

@@ -1,7 +1,7 @@
 (ns frontend.handler.worker
   "Handle messages received from the db worker"
   (:require [cljs-bean.core :as bean]
-            [frontend.handler.file :as file-handler]
+            [frontend.handler.file-based.file :as file-handler]
             [frontend.handler.notification :as notification]
             [frontend.state :as state]
             [lambdaisland.glogi :as log]