fix: notify users to switch to the new filename format

Notify users to switch to the new filename format if there're reserved
chars when syncing.

Also, this commit replace all `js/decodeURIComponent` with
`safe-decode-uri-component` to avoid UI crashes.
This commit is contained in:
Tienson Qin
2022-11-06 21:17:29 +08:00
parent a8eb7810a9
commit dd0169b068
15 changed files with 84 additions and 28 deletions

View File

@@ -54,6 +54,7 @@
[frontend.handler.file-sync :as file-sync-handler]
[frontend.components.file-sync :as file-sync]
[frontend.components.encryption :as encryption]
[frontend.components.conversion :as conversion-component]
[goog.dom :as gdom]
[logseq.db.schema :as db-schema]
[promesa.core :as p]
@@ -705,6 +706,33 @@
(when (= dir (config/get-repo-dir repo))
(fs/watch-dir! dir))))
(defmethod handle :ui/notify-files-with-reserved-chars [[_ paths]]
(sync/<sync-stop)
(notification/show!
[:div
[:div.mb-4
[:div.font-semibold.mb-4.text-xl "It seems that you're using the old filename format."]
[:div
[:p
"We suggest you upgrading 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."]]
]
(ui/button
"Upgrade filename format"
:on-click (fn []
(state/close-modal!)
(state/set-modal!
(fn [_] (conversion-component/files-breaking-changed))
{:id :filename-format-panel :center? true})))
[:ol.my-2
(for [path paths]
[:li path])]]
: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!)))