瀏覽代碼

feat: notify users to update filename format

Junyi 2 年之前
父節點
當前提交
4898ef8ee1

+ 1 - 1
src/main/frontend/fs/sync.cljs

@@ -494,7 +494,7 @@
         reserved-paths (filter f paths)]
     (when (seq reserved-paths)
       (let [paths (if path-string? reserved-paths (map -relative-path reserved-paths))]
-        (state/pub-event! [:ui/notify-files-with-reserved-chars paths])
+        (state/pub-event! [:ui/notify-outdated-filename-format paths])
         (prn "Skipped uploading those file paths with reserved chars: " paths)))
     (vec (remove f paths))))
 

+ 16 - 7
src/main/frontend/handler/events.cljs

@@ -359,7 +359,13 @@
       (when-not dir-exists?
         (state/pub-event! [:graph/dir-gone dir]))))
   ;; FIXME: an ugly implementation for redirecting to page on new window is restored
-  (repo-handler/graph-ready! repo))
+  (repo-handler/graph-ready! repo)
+  (when (and (util/electron?)
+             (not (config/demo-graph?))
+             (= :legacy (state/get-filename-format))
+             (not (get-in (state/get-config) [:file/name-format-skip-check] false)))
+    (state/pub-event! [:ui/notify-outdated-filename-format []]))
+  )
 
 (defmethod handle :notification/show [[_ {:keys [content status clear?]}]]
   (notification/show! content status clear?))
@@ -738,7 +744,8 @@
     (when (= dir (config/get-repo-dir repo))
       (fs/watch-dir! dir))))
 
-(defmethod handle :ui/notify-files-with-reserved-chars [[_ paths]]
+(defmethod handle :ui/notify-outdated-filename-format [[_ paths]]
+  ;; paths - the affected paths that contains reserved characters
   (notification/show!
    [:div
     [:div.mb-4
@@ -747,8 +754,9 @@
      [:div
       [:p
        "We suggest you upgrade now to avoid some potential bugs."]
-      [:p
-       "For example, the files below have reserved characters can't be synced on some platforms."]]
+      (when (seq? paths)
+        [:p
+         "For example, the files below have reserved characters can't be synced on some platforms."])]
      ]
     (ui/button
       "Update filename format"
@@ -757,9 +765,10 @@
                   (state/set-modal!
                   (fn [_] (conversion-component/files-breaking-changed))
                   {:id :filename-format-panel :center? true})))
-    [:ol.my-2
-     (for [path paths]
-       [:li path])]]
+    (when (seq? paths)
+      [:ol.my-2
+       (for [path paths]
+         [:li path])])]
    :warning
    false))
 

+ 1 - 1
src/main/frontend/handler/page.cljs

@@ -100,7 +100,7 @@
 (defn- create-title-property?
   [journal? page-name]
   (and (not journal?)
-       (not= (state/get-filename-format) :triple-lowbar)
+       (= (state/get-filename-format) :legacy) ;; reduce title computation
        (fs-util/create-title-property? page-name)))
 
 (defn- build-page-tx [format properties page journal? whiteboard?]

+ 2 - 1
src/main/frontend/util/fs.cljs

@@ -179,7 +179,8 @@
    (when (string? title)
      (case file-name-format
        :triple-lowbar (tri-lb-file-name-sanity title)
-       :legacy-dot    (legacy-dot-file-name-sanity title) ;; The earliest file name rule (before May 2022). For file name check in the conversion logic only. Don't allow users to use this.
+       ;; The earliest file name rule (before May 2022). For file name check in the conversion logic only. Don't allow users to use this or show up in config, as it's not handled.
+       :legacy-dot    (legacy-dot-file-name-sanity title)
        (legacy-url-file-name-sanity title)))))
 
 (defn create-title-property?