浏览代码

fix: lint

Tienson Qin 8 月之前
父节点
当前提交
d1557a0599

+ 0 - 1
src/main/frontend/handler/history.cljs

@@ -7,7 +7,6 @@
             [frontend.state :as state]
             [frontend.state :as state]
             [frontend.undo-redo :as undo-redo]
             [frontend.undo-redo :as undo-redo]
             [frontend.util :as util]
             [frontend.util :as util]
-            [frontend.util.page :as page-util]
             [goog.functions :refer [debounce]]
             [goog.functions :refer [debounce]]
             [logseq.db :as ldb]
             [logseq.db :as ldb]
             [promesa.core :as p]))
             [promesa.core :as p]))

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

@@ -4,7 +4,6 @@
   (:require [borkdude.rewrite-edn :as rewrite]
   (:require [borkdude.rewrite-edn :as rewrite]
             [cljs-bean.core :as bean]
             [cljs-bean.core :as bean]
             [clojure.string :as string]
             [clojure.string :as string]
-            [datascript.core :as d]
             [electron.ipc :as ipc]
             [electron.ipc :as ipc]
             [frontend.config :as config]
             [frontend.config :as config]
             [frontend.date :as date]
             [frontend.date :as date]

+ 3 - 12
src/main/frontend/util/page.cljs

@@ -1,8 +1,8 @@
 (ns frontend.util.page
 (ns frontend.util.page
   "Provides util fns for page blocks"
   "Provides util fns for page blocks"
-  (:require [frontend.state :as state]
-            [frontend.util :as util]
-            [frontend.db :as db]))
+  (:require [frontend.db :as db]
+            [frontend.state :as state]
+            [frontend.util :as util]))
 
 
 (defn get-current-page-name
 (defn get-current-page-name
   "Fetch the current page's original name with same approach as get-current-page-id"
   "Fetch the current page's original name with same approach as get-current-page-id"
@@ -23,15 +23,6 @@
   (let [page-name (state/get-current-page)]
   (let [page-name (state/get-current-page)]
     (:db/id (db/get-page page-name))))
     (:db/id (db/get-page page-name))))
 
 
-(defn get-latest-edit-page-id
-  "Fetch the editing page id. If there is an edit-input-id set, we are probably still
-   on editing mode"
-  []
-  (or
-    (get-in (first (state/get-editor-args)) [:block :block/page :db/id])
-    ;; not found
-    (get-current-page-id)))
-
 (defn get-page-file-rpath
 (defn get-page-file-rpath
   "Gets the file path of a page. If no page is given, detects the current page.
   "Gets the file path of a page. If no page is given, detects the current page.
 Returns nil if no file path is found or no page is detected or given"
 Returns nil if no file path is found or no page is detected or given"

+ 2 - 1
src/main/frontend/worker/shared_service.cljs

@@ -1,4 +1,5 @@
 (ns frontend.worker.shared-service
 (ns frontend.worker.shared-service
+  "This allows multiple workers to share some resources (e.g. db access)"
   (:require [cljs-bean.core :as bean]
   (:require [cljs-bean.core :as bean]
             [frontend.worker.util :as worker-util]
             [frontend.worker.util :as worker-util]
             [goog.object :as gobj]
             [goog.object :as gobj]
@@ -84,7 +85,7 @@
    (reset! *client-channel nil)
    (reset! *client-channel nil)
    (reset! *requests-in-flight {})))
    (reset! *requests-in-flight {})))
 
 
-(defn create-service
+(defn ^:large-vars/cleanup-todo create-service
   [service-name target {:keys [on-provider-change]}]
   [service-name target {:keys [on-provider-change]}]
   (p/do!
   (p/do!
    (clear-old-service!)
    (clear-old-service!)

+ 11 - 13
src/test/frontend/worker/undo_redo_test.cljs → src/test/frontend/undo_redo_test.cljs

@@ -1,4 +1,4 @@
-(ns frontend.worker.undo-redo-test
+(ns frontend.undo-redo-test
   (:require [clojure.test :as t :refer [deftest is testing use-fixtures]]
   (:require [clojure.test :as t :refer [deftest is testing use-fixtures]]
             [datascript.core :as d]
             [datascript.core :as d]
             [frontend.db :as db]
             [frontend.db :as db]
@@ -6,8 +6,7 @@
             [frontend.state :as state]
             [frontend.state :as state]
             [frontend.test.fixtures :as fixtures]
             [frontend.test.fixtures :as fixtures]
             [frontend.test.helper :as test-helper]
             [frontend.test.helper :as test-helper]
-            [frontend.worker.db-listener :as worker-db-listener]
-            [frontend.worker.undo-redo :as undo-redo]))
+            [frontend.undo-redo :as undo-redo]))
 
 
 ;; TODO: random property ops test
 ;; TODO: random property ops test
 
 
@@ -17,8 +16,7 @@
   [f]
   [f]
   (let [test-db-conn (db/get-db test-db false)]
   (let [test-db-conn (db/get-db test-db false)]
     (assert (some? test-db-conn))
     (assert (some? test-db-conn))
-    (worker-db-listener/listen-db-changes! test-db test-db-conn
-                                           {:handler-keys [:gen-undo-ops]})
+    (undo-redo/listen-db-changes! test-db test-db-conn)
 
 
     (f)
     (f)
     (d/unlisten! test-db-conn :frontend.worker.db-listener/listen-db-changes!)))
     (d/unlisten! test-db-conn :frontend.worker.db-listener/listen-db-changes!)))
@@ -36,18 +34,18 @@
   listen-db-fixture)
   listen-db-fixture)
 
 
 (defn- undo-all!
 (defn- undo-all!
-  [conn]
+  []
   (loop [i 0]
   (loop [i 0]
-    (let [r (undo-redo/undo test-db conn)]
-      (if (not= :frontend.worker.undo-redo/empty-undo-stack r)
+    (let [r (undo-redo/undo test-db)]
+      (if (not= :frontend.undo-redo/empty-undo-stack r)
         (recur (inc i))
         (recur (inc i))
         (prn :undo-count i)))))
         (prn :undo-count i)))))
 
 
 (defn- redo-all!
 (defn- redo-all!
-  [conn]
+  []
   (loop [i 0]
   (loop [i 0]
-    (let [r (undo-redo/redo test-db conn)]
-      (if (not= :frontend.worker.undo-redo/empty-redo-stack r)
+    (let [r (undo-redo/redo test-db)]
+      (if (not= :frontend.undo-redo/empty-redo-stack r)
         (recur (inc i))
         (recur (inc i))
         (prn :redo-count i)))))
         (prn :redo-count i)))))
 
 
@@ -64,10 +62,10 @@
             _ (outliner-test/run-random-mixed-ops! *random-blocks)
             _ (outliner-test/run-random-mixed-ops! *random-blocks)
             db-after @conn]
             db-after @conn]
 
 
-        (undo-all! conn)
+        (undo-all!)
 
 
         (is (= (get-datoms @conn) #{}))
         (is (= (get-datoms @conn) #{}))
 
 
-        (redo-all! conn)
+        (redo-all!)
 
 
         (is (= (get-datoms @conn) (get-datoms db-after)))))))
         (is (= (get-datoms @conn) (get-datoms db-after)))))))