Tienson Qin hai 7 meses
pai
achega
d1557a0599

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

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

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

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

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

@@ -1,8 +1,8 @@
 (ns frontend.util.page
   "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
   "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)]
     (: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
   "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"

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

@@ -1,4 +1,5 @@
 (ns frontend.worker.shared-service
+  "This allows multiple workers to share some resources (e.g. db access)"
   (:require [cljs-bean.core :as bean]
             [frontend.worker.util :as worker-util]
             [goog.object :as gobj]
@@ -84,7 +85,7 @@
    (reset! *client-channel nil)
    (reset! *requests-in-flight {})))
 
-(defn create-service
+(defn ^:large-vars/cleanup-todo create-service
   [service-name target {:keys [on-provider-change]}]
   (p/do!
    (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]]
             [datascript.core :as d]
             [frontend.db :as db]
@@ -6,8 +6,7 @@
             [frontend.state :as state]
             [frontend.test.fixtures :as fixtures]
             [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
 
@@ -17,8 +16,7 @@
   [f]
   (let [test-db-conn (db/get-db test-db false)]
     (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)
     (d/unlisten! test-db-conn :frontend.worker.db-listener/listen-db-changes!)))
@@ -36,18 +34,18 @@
   listen-db-fixture)
 
 (defn- undo-all!
-  [conn]
+  []
   (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))
         (prn :undo-count i)))))
 
 (defn- redo-all!
-  [conn]
+  []
   (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))
         (prn :redo-count i)))))
 
@@ -64,10 +62,10 @@
             _ (outliner-test/run-random-mixed-ops! *random-blocks)
             db-after @conn]
 
-        (undo-all! conn)
+        (undo-all!)
 
         (is (= (get-datoms @conn) #{}))
 
-        (redo-all! conn)
+        (redo-all!)
 
         (is (= (get-datoms @conn) (get-datoms db-after)))))))