Forráskód Böngészése

Add instructions when downloading files that have reserved chars

Tienson Qin 3 éve
szülő
commit
9d29a51314

+ 1 - 1
src/main/frontend/components/file_sync.cljs

@@ -463,7 +463,7 @@
                                      {:key (str "queue-" path)}
                                      (try
                                        (gp-util/safe-decode-uri-component path)
-                                       (catch :default e
+                                       (catch :default _
                                          (prn "Wrong path: " path)
                                          path))]
                              :key   (str "queue-" path)

+ 3 - 0
src/main/frontend/fs/sync.cljs

@@ -464,11 +464,14 @@
    (boolean)))
 
 (defn- filter-files-with-reserved-chars
+  "Skip downloading file paths with reserved chars."
   [files]
   (let [reserved-files (filter
                         #(fs-util/include-reserved-chars? (-relative-path %))
                         files)]
     (when (seq reserved-files)
+      (state/pub-event! [:ui/notify-skipped-downloading-files
+                         (map -relative-path reserved-files)])
       (prn "Skipped downloading those file paths with reserved chars: "
            (map -relative-path reserved-files))
       )

+ 25 - 2
src/main/frontend/handler/events.cljs

@@ -716,9 +716,9 @@
 
      [:div
       [:p
-       "We suggest you upgrading now to avoid some potential bugs."]
+       "We suggest you upgrade now to avoid some potential bugs."]
       [:p
-       "For example, the files below have reserved characters that make them unable to be synced on some platforms."]]
+       "For example, the files below have reserved characters can't be synced on some platforms."]]
      ]
     (ui/button
       "Upgrade filename format"
@@ -733,6 +733,29 @@
    :warning
    false))
 
+(defmethod handle :ui/notify-skipped-downloading-files [[_ paths]]
+  (notification/show!
+   [:div
+    [:div.mb-4
+     [:div.font-semibold.mb-4.text-xl "It seems that you're using the old filename format."]
+     [:p
+      "The files below that have reserved characters can't be saved on this device."]
+     [:div.overflow-y-auto.max-h-96
+      [:ol.my-2
+       (for [path paths]
+         [:li path])]]
+
+     [:div
+      [:p
+       "Check " [:a {:href "https://docs.logseq.com/#/page/logseq%20file%20and%20folder%20naming%20rules"
+                     :target "_blank"}
+                 "https://docs.logseq.com/#/page/logseq%20file%20and%20folder%20naming%20rules"]
+       " for more details."]
+      [:p
+       "To solve this problem, we suggest you upgrade the filename format (on Settings > Advanced > Filename format > click EDIT button) in other devices to avoid more potential bugs."]]]]
+   :warning
+   false))
+
 (defmethod handle :file/alter [[_ repo path content]]
   (p/let [_ (file-handler/alter-file repo path content {:from-disk? true})]
     (ui-handler/re-render-root!)))