|
|
@@ -10,7 +10,6 @@
|
|
|
[clojure.core.async.interop :refer [p->c]]
|
|
|
[clojure.set :as set]
|
|
|
[clojure.string :as string]
|
|
|
- [datascript.core :as d]
|
|
|
[frontend.commands :as commands]
|
|
|
[frontend.components.command-palette :as command-palette]
|
|
|
[frontend.components.conversion :as conversion-component]
|
|
|
@@ -507,22 +506,7 @@
|
|
|
(when-let [toolbar (.querySelector main-node "#mobile-editor-toolbar")]
|
|
|
(set! (.. toolbar -style -bottom) 0)))))
|
|
|
|
|
|
-(defn update-file-path [deprecated-repo current-repo deprecated-app-id current-app-id]
|
|
|
- (let [files (db-model/get-files-entity deprecated-repo)
|
|
|
- conn (conn/get-db deprecated-repo false)
|
|
|
- tx (mapv (fn [[id path]]
|
|
|
- (let [new-path (string/replace path deprecated-app-id current-app-id)]
|
|
|
- {:db/id id
|
|
|
- :file/path new-path}))
|
|
|
- files)]
|
|
|
- (d/transact! conn tx)
|
|
|
- (reset! conn/conns
|
|
|
- (update-keys @conn/conns
|
|
|
- (fn [key] (if (string/includes? key deprecated-repo)
|
|
|
- (string/replace key deprecated-repo current-repo)
|
|
|
- key))))))
|
|
|
-
|
|
|
-(defn get-ios-app-id
|
|
|
+(defn- get-ios-app-id
|
|
|
[repo-url]
|
|
|
(when repo-url
|
|
|
(let [app-id (-> (first (string/split repo-url "/Documents"))
|
|
|
@@ -532,11 +516,12 @@
|
|
|
|
|
|
(defmethod handle :validate-appId [[_ graph-switch-f graph]]
|
|
|
(when-let [deprecated-repo (or graph (state/get-current-repo))]
|
|
|
- ;; Installation is not changed for iCloud
|
|
|
(if (mobile-util/in-iCloud-container-path? deprecated-repo)
|
|
|
+ ;; Installation is not changed for iCloud
|
|
|
(when graph-switch-f
|
|
|
(graph-switch-f graph true)
|
|
|
(state/pub-event! [:graph/ready (state/get-current-repo)]))
|
|
|
+ ;; Installation is changed for App Documents directory
|
|
|
(p/let [deprecated-app-id (get-ios-app-id deprecated-repo)
|
|
|
current-document-url (.getUri Filesystem #js {:path ""
|
|
|
:directory (.-Documents Directory)})
|
|
|
@@ -545,24 +530,34 @@
|
|
|
(if (= deprecated-app-id current-app-id)
|
|
|
(when graph-switch-f (graph-switch-f graph true))
|
|
|
(do
|
|
|
+ (notification/show! [:div "Migrating from previous App installation..."]
|
|
|
+ :warning
|
|
|
+ true)
|
|
|
+ (prn ::migrate-app-id :from deprecated-app-id :to current-app-id)
|
|
|
(file-sync-stop!)
|
|
|
(.unwatch mobile-util/fs-watcher)
|
|
|
(let [current-repo (string/replace deprecated-repo deprecated-app-id current-app-id)
|
|
|
current-repo-dir (config/get-repo-dir current-repo)]
|
|
|
(try
|
|
|
- (update-file-path deprecated-repo current-repo deprecated-app-id current-app-id)
|
|
|
- (db-persist/delete-graph! deprecated-repo)
|
|
|
+ ;; replace app-id part of repo url
|
|
|
+ (reset! conn/conns
|
|
|
+ (update-keys @conn/conns
|
|
|
+ (fn [key]
|
|
|
+ (if (string/includes? key deprecated-app-id)
|
|
|
+ (string/replace key deprecated-app-id current-app-id)
|
|
|
+ key))))
|
|
|
+ (db-persist/rename-graph! deprecated-repo current-repo)
|
|
|
(search/remove-db! deprecated-repo)
|
|
|
- (state/delete-repo! {:url deprecated-repo})
|
|
|
(state/add-repo! {:url current-repo :nfs? true})
|
|
|
+ (state/delete-repo! {:url deprecated-repo})
|
|
|
(catch :default e
|
|
|
(js/console.error e)))
|
|
|
(state/set-current-repo! current-repo)
|
|
|
(db/listen-and-persist! current-repo)
|
|
|
(db/persist-if-idle! current-repo)
|
|
|
(repo-config-handler/restore-repo-config! current-repo)
|
|
|
- (.watch mobile-util/fs-watcher #js {:path current-repo-dir})
|
|
|
(when graph-switch-f (graph-switch-f current-repo true))
|
|
|
+ (.watch mobile-util/fs-watcher #js {:path current-repo-dir})
|
|
|
(file-sync-restart!))))
|
|
|
(state/pub-event! [:graph/ready (state/get-current-repo)])))))
|
|
|
|