Browse Source

fix: handle a property :default to :page change

Part of LOG-2985. :page property values would just be references so
use properties-text-values over `str`. Also added import timing
Gabriel Horner 1 year ago
parent
commit
4f3c4c9e03

+ 6 - 5
deps/graph-parser/src/logseq/graph_parser/exporter.cljs

@@ -181,13 +181,13 @@
                  val)]))
        (into {})))
 
-(defn- update-user-property-values [props user-page-properties prop-name->uuid property-changes]
+(defn- update-user-property-values [props user-page-properties prop-name->uuid properties-text-values property-changes]
   (->> props
        (map (fn [[prop val]]
               [prop
                (cond
                  (= :default (get-in @property-changes [prop :type :from]))
-                 (str val)
+                 (or (get properties-text-values prop) (str val))
                  (contains? user-page-properties prop)
                  ;; assume for now a ref's :block/name can always be translated by lc helper
                  (set (map (comp prop-name->uuid common-util/page-name-sanity-lc) val))
@@ -203,7 +203,7 @@
 
 (defn- update-block-properties*
   "Updates block property names and values and removes old built-in properties"
-  [*props db page-names-to-uuids {:keys [whiteboard? property-changes]}]
+  [*props db page-names-to-uuids properties-text-values {:keys [whiteboard? property-changes]}]
   (let [prop-name->uuid (if whiteboard?
                           (fn prop-name->uuid [k]
                             (or (get-pid db k)
@@ -225,7 +225,7 @@
         (seq (select-keys props db-property/built-in-properties-keys))
         (update-built-in-property-values db)
         (or (seq user-page-properties) (seq @property-changes))
-        (update-user-property-values user-page-properties prop-name->uuid property-changes)
+        (update-user-property-values user-page-properties prop-name->uuid properties-text-values property-changes)
         true
         (update-keys prop-name->uuid)))))
 
@@ -247,7 +247,8 @@
   (if (:block/pre-block? block)
   ;; FIXME: Remove when page properties are supported
     (assoc block :block/properties {})
-    (update-in block [:block/properties] #(update-block-properties* % db page-names-to-uuids options))))
+    (update-in block [:block/properties]
+               #(update-block-properties* % db page-names-to-uuids (:block/properties-text-values block) options))))
 
 (defn- convert-to-db-block
   [db block tag-classes page-names-to-uuids options]

+ 5 - 2
src/main/frontend/components/imports.cljs

@@ -4,6 +4,7 @@
             [clojure.core.async :as async]
             [clojure.edn :as edn]
             [clojure.string :as string]
+            [cljs-time.core :as t]
             [datascript.core :as d]
             [frontend.components.onboarding.setups :as setups]
             [frontend.components.repo :as repo]
@@ -342,8 +343,9 @@
   (state/set-state! :graph/importing :file-graph)
   (state/set-state! [:graph/importing-state :current-page] (str graph-name " Assets"))
   (async/go
-    (async/<! (p->c (repo-handler/new-db! graph-name {:file-graph-import? true})))
-    (let [repo (state/get-current-repo)
+    (let [start-time (t/now)
+          _ (async/<! (p->c (repo-handler/new-db! graph-name {:file-graph-import? true})))
+          repo (state/get-current-repo)
           db-conn (db/get-db repo false)
           config (async/<! (p->c (import-config-file! config-file)))
           files (common-config/remove-hidden-files *files config :rpath)
@@ -357,6 +359,7 @@
       (async/<! (import-from-doc-files! db-conn repo config doc-files
                                         {:tag-classes (set (string/split tags #",\s*"))}))
       (async/<! (p->c (import-favorites-from-config-edn! db-conn repo config-file)))
+      (log/info :import-file-graph {:msg (str "Import finished in " (/ (t/in-millis (t/interval start-time (t/now))) 1000) " seconds")})
       (state/set-state! :graph/importing nil)
       (state/set-state! :graph/importing-state nil)
       (when-let [org-files (seq (filter #(= "org" (path/file-ext (:rpath %))) files))]