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

fix(sync): page history on mobile platforms

Andelf 2 лет назад
Родитель
Сommit
3406795066
2 измененных файлов с 12 добавлено и 12 удалено
  1. 10 10
      src/main/frontend/handler/file_sync.cljs
  2. 2 2
      src/main/frontend/util/fs.cljs

+ 10 - 10
src/main/frontend/handler/file_sync.cljs

@@ -16,7 +16,8 @@
             [cljs-time.coerce :as tc]
             [cljs-time.core :as t]
             [frontend.storage :as storage]
-            [lambdaisland.glogi :as log]))
+            [lambdaisland.glogi :as log]
+            [logseq.common.path :as path]))
 
 (def *beta-unavailable? (volatile! false))
 
@@ -130,19 +131,16 @@
                                 [:div "Downloaded version file at: "]
                                 [:div key]] :success false)))
        (when-not (instance? ExceptionInfo r)
-         (node-path/join "logseq" "version-files" key))))))
+         (path/path-join "logseq" "version-files" key))))))
 
 (defn- <list-file-local-versions
   [page]
   (go
     (when-let [path (-> page :block/file :file/path)]
-      (let [base-path           (config/get-repo-dir (state/get-current-repo))
-            rel-path            (string/replace-first path base-path "")
-            version-files-dir   (->> (node-path/join "logseq/version-files/local" rel-path)
-                                     node-path/parse
-                                     (#(js->clj % :keywordize-keys true))
-                                     ((juxt :dir :name))
-                                     (apply node-path/join base-path))
+      (let [base-path          (config/get-repo-dir (state/get-current-repo))
+            rel-path           (string/replace-first path base-path "")
+            file-stem          (path/file-stem rel-path)
+            version-files-dir  (path/path-join base-path "logseq/version-files/local" (path/dirname rel-path) file-stem)
             version-file-paths (<! (p->c (fs/readdir version-files-dir :path-only? true)))]
         (when-not (instance? ExceptionInfo version-file-paths)
           (when (seq version-file-paths)
@@ -155,7 +153,9 @@
                             (js->clj :keywordize-keys true)
                             :name
                             (#(tf/parse (tf/formatter "yyyy-MM-dd'T'HH_mm_ss.SSSZZ") %)))]
-                    {:create-time create-time :path path :relative-path (string/replace-first path base-path "")})
+                    {:create-time   create-time
+                     :path          path
+                     :relative-path (path/relative-path base-path path)})
                   (catch :default e
                     (log/error :page-history/parse-format-error e)
                     nil)))

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

@@ -69,9 +69,9 @@
     []))
 
 (defn read-repo-file
-  [repo-url file]
+  [repo-url file-rpath]
   (when-let [repo-dir (config/get-repo-dir repo-url)]
-    (fs/read-file repo-dir file)))
+    (fs/read-file repo-dir file-rpath)))
 
 (def multiplatform-reserved-chars ":\\*\\?\"<>|\\#\\\\")