Просмотр исходного кода

enhance: migrate imported config to be valid

Also improves import ux as Invalid config notification no longer blocks
import progress
Gabriel Horner 2 лет назад
Родитель
Сommit
3f3cf8b17f

+ 7 - 3
src/main/frontend/components/imports.cljs

@@ -26,6 +26,7 @@
             [logseq.graph-parser :as graph-parser]
             [medley.core :as medley]
             [promesa.core :as p]
+            [borkdude.rewrite-edn :as rewrite]
             [rum.core :as rum]
             [frontend.handler.repo :as repo-handler]))
 
@@ -208,10 +209,13 @@
   (-> (when config-file
         (.text config-file))
       (p/then (fn [content]
-                (when content
+                (let [migrated-content (-> (reduce rewrite/dissoc
+                                                   (rewrite/parse-string (str content))
+                                                   [:preferred-format :property/separated-by-commas])
+                                           str)]
                   (p/do!
-                   (db-editor-handler/save-file! "logseq/config.edn" content))
-                  (edn/read-string content))))))
+                   (db-editor-handler/save-file! "logseq/config.edn" migrated-content))
+                  (edn/read-string migrated-content))))))
 
 
 (rum/defc confirm-graph-name-dialog

+ 3 - 1
src/main/frontend/handler/common/config_edn.cljs

@@ -97,7 +97,9 @@ nested keys or positional errors e.g. tuples"
                    db-graph?
                    (merge
                     {:preferred-format
-                     "is not used in DB graphs as there is only markdown mode."}))]
+                     "is not used in DB graphs as there is only markdown mode."
+                     :property/separated-by-commas
+                     "is not used in DB graphs"}))]
     (cond
       (= body ::failed-to-detect)
       (log/info :msg "Skip deprecation check since config is not valid edn")