Bläddra i källkod

Merge branch 'feat/db' into feat/capacitor-new

charlie 5 månader sedan
förälder
incheckning
f009596a54

+ 1 - 1
.github/workflows/build.yml

@@ -2,7 +2,7 @@ name: CI
 
 on:
   push:
-    branches: [master, "feat/db"]
+    branches: [master]
     paths-ignore:
       - '*.md'
   pull_request:

+ 3 - 3
.github/workflows/clj-e2e.yml

@@ -2,7 +2,7 @@ name: Clojure E2E
 
 on:
   push:
-    branches: [master, "feat/db"]
+    branches: [master]
     paths:
       - 'clj-e2e/**'
       - '.github/workflows/clj-e2e.yml'
@@ -84,8 +84,8 @@ jobs:
 
       - name: Run e2e tests
         run: cd clj-e2e && timeout 30m bb dev
-        env:
-          DEBUG: "pw:api"
+        # env:
+        #   DEBUG: "pw:api"
 
       - name: Collect screenshots
         if: ${{ failure() }}

+ 1 - 1
.github/workflows/clj-rtc-e2e.yml

@@ -2,7 +2,7 @@ name: Clojure RTC E2E
 
 on:
   push:
-    branches: [master, "feat/db"]
+    branches: [master]
     paths:
       - 'clj-e2e/**'
       - '.github/workflows/clj-rtc-e2e.yml'

+ 1 - 1
.github/workflows/db.yml

@@ -3,7 +3,7 @@ name: logseq/db CI
 on:
   # Path filters ensure jobs only kick off if a change is made to db
   push:
-    branches: [master, "feat/db"]
+    branches: [master]
     paths:
       - 'deps/db/**'
       - '.github/workflows/db.yml'

+ 1 - 1
.github/workflows/graph-parser.yml

@@ -4,7 +4,7 @@ on:
   # Path filters ensure jobs only kick off if a change is made to graph-parser or
   # its local dependencies
   push:
-    branches: [master, "feat/db"]
+    branches: [master]
     paths:
       - 'deps/graph-parser/**'
       # db is a local dep that could break functionality in this lib and should trigger this

+ 1 - 1
.github/workflows/logseq-common.yml

@@ -3,7 +3,7 @@ name: logseq/common CI
 on:
   # Path filters ensure jobs only kick off if a change is made to common
   push:
-    branches: [master, "feat/db"]
+    branches: [master]
     paths:
       - 'deps/common/**'
       - '.github/workflows/logseq-common.yml'

+ 1 - 1
.github/workflows/outliner.yml

@@ -4,7 +4,7 @@ on:
   # Path filters ensure jobs only kick off if a change is made to outliner or
   # its local dependencies
   push:
-    branches: [master, "feat/db"]
+    branches: [master]
     paths:
       - 'deps/outliner/**'
       # db is a local dep that could break functionality in this lib and should trigger this

+ 1 - 1
.github/workflows/publishing.yml

@@ -4,7 +4,7 @@ on:
   # Path filters ensure jobs only kick off if a change is made to publishing or
   # its local dependencies
   push:
-    branches: [master, "feat/db"]
+    branches: [master]
     paths:
       - 'deps/publishing/**'
       # db is a local dep that could break functionality in this lib and should trigger this

+ 1 - 1
deps/db/deps.edn

@@ -11,7 +11,7 @@
   ;; Any other deps should be added here and to nbb.edn
   logseq/common                {:local/root "../common"}
   logseq/clj-fractional-indexing        {:git/url "https://github.com/logseq/clj-fractional-indexing"
-                                         :sha     "7182b7878410f78536dc2b6df35ed32ef9cd6b61"}
+                                         :sha     "1087f0fb18aa8e25ee3bbbb0db983b7a29bce270"}
   borkdude/rewrite-edn {:mvn/version "0.4.9"}
   metosin/malli {:mvn/version "0.16.1"}
   medley/medley {:mvn/version "1.4.0"}}

+ 1 - 1
deps/db/nbb.edn

@@ -7,7 +7,7 @@
   ;; Used by db scripts with outliner.cli
   borkdude/rewrite-edn {:mvn/version "0.4.9"}
   logseq/clj-fractional-indexing        {:git/url "https://github.com/logseq/clj-fractional-indexing"
-                                         :sha     "7182b7878410f78536dc2b6df35ed32ef9cd6b61"}
+                                         :sha     "1087f0fb18aa8e25ee3bbbb0db983b7a29bce270"}
   io.github.nextjournal/nbb-test-runner
   {:git/sha "012017a8a8983d05f905f38f631f5222f25b9ed9"}
   io.github.pez/baldr {:mvn/version "1.0.9"}}}

+ 4 - 1
deps/db/src/logseq/db/sqlite/build.cljs

@@ -645,7 +645,7 @@
     @uuids))
 
 (defn- build-blocks-tx*
-  [{:keys [pages-and-blocks properties auto-create-ontology?]
+  [{:keys [pages-and-blocks properties auto-create-ontology? build-existing-tx?]
     :as options}]
   (let [pages-and-blocks' (pre-build-pages-and-blocks pages-and-blocks properties (dissoc options :pages-and-blocks :properties))
         page-uuids (create-page-uuids pages-and-blocks')
@@ -662,6 +662,9 @@
                                            (mapv #(if (db-class/logseq-class? (:db/ident %))
                                                     %
                                                     (or (some->> (:db/ident %) class-ident->id (hash-map :db/id))
+                                                        ;; Allow existing user classes to be specified as idents
+                                                        (when (and build-existing-tx? (some->> (:db/ident %) (get classes)))
+                                                          (:db/ident %))
                                                         (throw (ex-info (str "No :db/id found for :db/ident " (pr-str %)) {}))))
                                                  cs)))
                                  m))

+ 1 - 1
package.json

@@ -4,7 +4,7 @@
     "private": true,
     "main": "static/electron.js",
     "engines" : {
-      "node" : ">=22.15.0"
+      "node" : ">=20.19.1"
     },
     "devDependencies": {
         "@axe-core/playwright": "=4.4.4",

+ 10 - 23
src/main/frontend/common/file/core.cljs

@@ -30,43 +30,30 @@
     content))
 
 (defn- transform-content
-  [repo db {:block/keys [collapsed? format pre-block? title page properties] :as b} level {:keys [heading-to-list?]} context]
-  (let [db-based? (sqlite-util/db-based-graph? repo)
-        block-ref-not-saved? (and (seq (:block/_refs (d/entity db (:db/id b))))
-                                  (not (string/includes? title (str (:block/uuid b))))
-                                  (not db-based?))
+  [repo db {:block/keys [collapsed? format pre-block? properties] :as b} level {:keys [heading-to-list?]} context {:keys [db-based?]}]
+  (let [title (or (:block/raw-title b) (:block/title b))
+        block-ref-not-saved? (and (not db-based?)
+                                  (first (:block/_refs (d/entity db (:db/id b))))
+                                  (not (string/includes? title (str (:block/uuid b)))))
         heading (:heading properties)
-        markdown? (= :markdown format)
         title (if db-based?
                 ;; replace [[uuid]] with block's content
                 (db-content/recur-replace-uuid-in-block-title (d/entity db (:db/id b)))
                 title)
         content (or title "")
-        page-first-child? (= (:db/id b) (ldb/get-first-child db (:db/id page)))
-        pre-block? (or pre-block?
-                       (and page-first-child?
-                            markdown?
-                            (string/includes? (first (string/split-lines content)) ":: ")))
         content (cond
                   pre-block?
                   (let [content (string/trim content)]
                     (str content "\n"))
 
                   :else
-                  (let [;; first block is a heading, Markdown users prefer to remove the `-` before the content
-                        markdown-top-heading? (and markdown?
-                                                   page-first-child?
-                                                   heading)
-                        [prefix spaces-tabs]
+                  (let [[prefix spaces-tabs]
                         (cond
                           (= format :org)
                           [(->>
                             (repeat level "*")
                             (apply str)) ""]
 
-                          markdown-top-heading?
-                          ["" ""]
-
                           :else
                           (let [level (if (and heading-to-list? heading)
                                         (if (> heading 1)
@@ -83,8 +70,7 @@
                                   content)
                         content (if db-based? content (content-with-collapsed-state repo format content collapsed?))
                         new-content (indented-block-content (string/trim content) spaces-tabs)
-                        sep (if (or markdown-top-heading?
-                                    (string/blank? new-content))
+                        sep (if (string/blank? new-content)
                               ""
                               " ")]
                     (str prefix sep new-content)))]
@@ -94,12 +80,13 @@
 
 (defn- tree->file-content-aux
   [repo db tree {:keys [init-level link] :as opts} context]
-  (let [block-contents (transient [])]
+  (let [db-based? (sqlite-util/db-based-graph? repo)
+        block-contents (transient [])]
     (loop [[f & r] tree level init-level]
       (if (nil? f)
         (->> block-contents persistent! flatten (remove nil?))
         (let [page? (nil? (:block/page f))
-              content (if (and page? (not link)) nil (transform-content repo db f level opts context))
+              content (if (and page? (not link)) nil (transform-content repo db f level opts context {:db-based? db-based?}))
               new-content
               (if-let [children (seq (:block/children f))]
                 (cons content (tree->file-content-aux repo db children {:init-level (inc level)} context))

+ 16 - 13
src/main/frontend/components/property.cljs

@@ -598,19 +598,22 @@
         hide-with-property-id (fn [property-id]
                                 (let [property (db/entity property-id)]
                                   (boolean
-                                   (when-not (or sidebar-properties? page-title?)
-                                     (cond
-                                       show-empty-and-hidden-properties?
-                                       false
-                                       root-block?
-                                       false
-                                       (and (:logseq.property/hide-empty-value property)
-                                            (nil? (get properties property-id)))
-                                       true
-                                       state-hide-empty-properties?
-                                       (nil? (get block property-id))
-                                       :else
-                                       (boolean (:logseq.property/hide? property)))))))
+                                   (cond
+                                     show-empty-and-hidden-properties?
+                                     false
+                                     state-hide-empty-properties?
+                                     (nil? (get block property-id))
+                                     :else
+                                     ;; For sidebar and page properties, ignore these checks
+                                     (when-not (or sidebar-properties? page-title?)
+                                       (cond
+                                         root-block?
+                                         false
+                                         (and (:logseq.property/hide-empty-value property)
+                                              (nil? (get properties property-id)))
+                                         true
+                                         :else
+                                         (boolean (:logseq.property/hide? property))))))))
         property-hide-f (cond
                           config/publishing?
                           ;; Publishing is read only so hide all blank properties as they

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

@@ -34,9 +34,10 @@
           (when-let [block (db/entity [:block/uuid block-id])]
             (let [format (get block :block/format :markdown)
                   content (:block/title block)
-                  properties (:block/properties block)
+                  ;; FIXME: Remove not-empty if :block/properties stops returning '()
+                  properties* (not-empty (:block/properties block))
                   properties-text-values (:block/properties-text-values block)
-                  properties (-> (merge properties new-properties)
+                  properties (-> (merge properties* new-properties)
                                  common-util/remove-nils-non-nested)
                   properties-text-values (-> (merge properties-text-values new-properties)
                                              common-util/remove-nils-non-nested)

+ 0 - 1
src/main/frontend/modules/shortcut/config.cljs

@@ -596,7 +596,6 @@
                 :fn commit/show-commit-modal!}
 
    :dev/fix-broken-graph {:binding []
-                          :inactive (not (state/developer-mode?))
                           :db-graph? true
                           :fn #(repo-handler/fix-broken-graph! (state/get-current-repo))}
 

+ 3 - 2
src/main/frontend/worker/db_worker.cljs

@@ -136,7 +136,8 @@
   (let [conn (worker-state/get-datascript-conn graph)
         sqlite-db (worker-state/get-sqlite-conn graph)]
     (when (and conn sqlite-db)
-      (rebuild-db-from-datoms! conn sqlite-db))))
+      (rebuild-db-from-datoms! conn sqlite-db)
+      (worker-util/post-message :notification ["The graph has been successfully rebuilt." :success false]))))
 
 (comment
   (defn- gc-kvs-table!
@@ -369,7 +370,7 @@
         ;; because it's slow for large graphs
         (when-not import-type
           (when-let [missing-addresses (seq (find-missing-addresses conn db))]
-            (worker-util/post-message :notification ["It seems that the DB has been broken, please export a backup and contact Logseq team for help." :error false])
+            (worker-util/post-message :notification ["It seems that the DB has been broken. Please run the command `Fix current broken graph`." :error false])
             (throw (ex-info "DB missing addresses" {:missing-addresses missing-addresses}))))
 
         (db-migrate/migrate conn search-db)

+ 1 - 1
src/resources/dicts/en.edn

@@ -787,7 +787,7 @@
   :dev/show-page-ast "(Dev) Show page AST"
   :dev/replace-graph-with-db-file "(Dev) Replace graph with its db.sqlite file"
   :dev/validate-db "(Dev) Validate current graph"
-  :dev/fix-broken-graph "(Dev) Fix current broken graph"
+  :dev/fix-broken-graph "Fix current broken graph"
   :dev/rtc-stop "(Dev) RTC Stop"
   :dev/rtc-start "(Dev) RTC Start"
   :window/close "Close window"}}