mirror of https://github.com/logseq/logseq
fix(mobile): refresh
parent
7101b8c491
commit
d0d25b5ad4
|
@ -11,5 +11,9 @@
|
|||
"splashImmersive": true,
|
||||
"backgroundColor": "#002b36"
|
||||
}
|
||||
},
|
||||
"server": {
|
||||
"url": "http://192.168.1.59:3001",
|
||||
"cleartext": true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,10 +16,10 @@ const config: CapacitorConfig = {
|
|||
}
|
||||
// do not commit this into source control
|
||||
// source: https://capacitorjs.com/docs/guides/live-reload
|
||||
// , server: {
|
||||
// url: process.env.LOGSEQ_APP_SERVER_URL,
|
||||
// cleartext: true
|
||||
// }
|
||||
, server: {
|
||||
url: process.env.LOGSEQ_APP_SERVER_URL,
|
||||
cleartext: true
|
||||
}
|
||||
};
|
||||
|
||||
export = config;
|
||||
|
|
|
@ -159,7 +159,7 @@
|
|||
(fn [_stat])
|
||||
(fn [error]
|
||||
(mkdir! dir))))
|
||||
(p/catch (fn [_error] nil))))
|
||||
(p/catch (fn [error] (js/console.error error)))))
|
||||
|
||||
(defn create-if-not-exists
|
||||
([repo dir path]
|
||||
|
|
|
@ -20,64 +20,73 @@
|
|||
(p/do!
|
||||
(.requestPermissions Filesystem)))))
|
||||
|
||||
(defn- clean-uri
|
||||
[uri]
|
||||
(when (string? uri)
|
||||
(-> uri
|
||||
(string/replace "file://" "")
|
||||
(futil/url-decode))))
|
||||
|
||||
(defn readdir
|
||||
"readdir recursively"
|
||||
[path]
|
||||
(p/loop [result []
|
||||
dirs [path]]
|
||||
(if (empty? dirs)
|
||||
result
|
||||
(p/let [d (first dirs)
|
||||
files (.readdir Filesystem (clj->js {:path d}))
|
||||
files (-> files
|
||||
js->clj
|
||||
(get "files" []))
|
||||
files (->> files
|
||||
(remove (fn [file] (string/starts-with? file "."))))
|
||||
files (->> files
|
||||
(map (fn [file] (futil/node-path.join d file))))
|
||||
_ (prn "files: ")
|
||||
_ (js/console.dir files)
|
||||
files-with-stats (p/all
|
||||
(mapv
|
||||
(fn [file]
|
||||
(p/chain
|
||||
(.stat Filesystem (clj->js {:path file}))
|
||||
#(js->clj % :keywordize-keys true)))
|
||||
files))
|
||||
files-dir (->> files-with-stats
|
||||
(filterv
|
||||
(fn [{:keys [type]}]
|
||||
(contains? #{"directory" "NSFileTypeDirectory"} type)))
|
||||
(mapv :uri))
|
||||
(p/let [result (p/loop [result []
|
||||
dirs [path]]
|
||||
(if (empty? dirs)
|
||||
result
|
||||
(p/let [d (first dirs)
|
||||
files (.readdir Filesystem (clj->js {:path d}))
|
||||
files (-> files
|
||||
js->clj
|
||||
(get "files" []))
|
||||
files (->> files
|
||||
(remove (fn [file]
|
||||
(or (string/starts-with? file ".")
|
||||
(= file "bak")))))
|
||||
files (->> files
|
||||
(map (fn [file]
|
||||
(futil/node-path.join d file))))
|
||||
files-with-stats (p/all
|
||||
(mapv
|
||||
(fn [file]
|
||||
(p/chain
|
||||
(.stat Filesystem (clj->js {:path file}))
|
||||
#(js->clj % :keywordize-keys true)))
|
||||
files))
|
||||
files-dir (->> files-with-stats
|
||||
(filterv
|
||||
(fn [{:keys [type]}]
|
||||
(contains? #{"directory" "NSFileTypeDirectory"} type)))
|
||||
(mapv :uri))
|
||||
|
||||
files-result
|
||||
(p/all
|
||||
(->> files-with-stats
|
||||
(filter
|
||||
(fn [{:keys [type]}]
|
||||
(contains? #{"file" "NSFileTypeRegular"} type)))
|
||||
(filter
|
||||
(fn [{:keys [uri]}]
|
||||
(some #(string/ends-with? uri %)
|
||||
[".md" ".markdown" ".org" ".edn" ".css"])))
|
||||
(mapv
|
||||
(fn [{:keys [uri] :as file-result}]
|
||||
(p/chain
|
||||
(.readFile Filesystem
|
||||
(clj->js
|
||||
{:path uri
|
||||
:encoding (.-UTF8 Encoding)}))
|
||||
#(js->clj % :keywordize-keys true)
|
||||
:data
|
||||
#(assoc file-result :content %))))))]
|
||||
(p/recur (concat result files-result)
|
||||
(concat (rest dirs) files-dir))))))
|
||||
files-result
|
||||
(p/all
|
||||
(->> files-with-stats
|
||||
(filter
|
||||
(fn [{:keys [type]}]
|
||||
(contains? #{"file" "NSFileTypeRegular"} type)))
|
||||
(filter
|
||||
(fn [{:keys [uri]}]
|
||||
(some #(string/ends-with? uri %)
|
||||
[".md" ".markdown" ".org" ".edn" ".css"])))
|
||||
(mapv
|
||||
(fn [{:keys [uri] :as file-result}]
|
||||
(p/chain
|
||||
(.readFile Filesystem
|
||||
(clj->js
|
||||
{:path uri
|
||||
:encoding (.-UTF8 Encoding)}))
|
||||
#(js->clj % :keywordize-keys true)
|
||||
:data
|
||||
#(assoc file-result :content %))))))]
|
||||
(p/recur (concat result files-result)
|
||||
(concat (rest dirs) files-dir)))))
|
||||
result (js->clj result :keywordize-keys true)]
|
||||
(map (fn [result] (update result :uri clean-uri)) result)))
|
||||
|
||||
(defrecord Capacitorfs []
|
||||
protocol/Fs
|
||||
(mkdir! [this dir]
|
||||
(prn "mkdir: " dir)
|
||||
(p/let [result (.mkdir Filesystem
|
||||
(clj->js
|
||||
{:path dir
|
||||
|
@ -106,7 +115,7 @@
|
|||
(p/let [content (.readFile Filesystem
|
||||
(clj->js
|
||||
{:path path
|
||||
:directory (.-ExternalStorage Directory)
|
||||
;; :directory (.-ExternalStorage Directory)
|
||||
:encoding (.-UTF8 Encoding)}))]
|
||||
content)
|
||||
(p/catch (fn [error]
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
[frontend.util :as util]
|
||||
[frontend.util.property :as property]
|
||||
[lambdaisland.glogi :as log]
|
||||
[promesa.core :as p]))
|
||||
[promesa.core :as p]
|
||||
[frontend.mobile.util :as mobile]))
|
||||
|
||||
(defn- extract-page-list
|
||||
[content]
|
||||
|
@ -150,7 +151,10 @@
|
|||
(p/resolved [])
|
||||
(p/let [format (format/get-format file)
|
||||
_ (println "Parsing start : " file)
|
||||
ast (mldoc/->edn-async content (mldoc/default-config format))]
|
||||
parse-f (if (mobile/is-native-platform?)
|
||||
mldoc/->edn
|
||||
mldoc/->edn-async)
|
||||
ast (parse-f content (mldoc/default-config format))]
|
||||
_ (println "Parsing finished : " file)
|
||||
(let [journal? (config/journal? file)
|
||||
first-block (ffirst ast)
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
[frontend.util :as util]
|
||||
[lambdaisland.glogi :as log]
|
||||
[promesa.core :as p]
|
||||
[frontend.debug :as debug]))
|
||||
[frontend.debug :as debug]
|
||||
[frontend.mobile.util :as mobile]))
|
||||
|
||||
;; TODO: extract all git ops using a channel
|
||||
|
||||
|
@ -134,7 +135,6 @@
|
|||
[repo-url file content]
|
||||
(let [electron-local-repo? (and (util/electron?)
|
||||
(config/local-db? repo-url))
|
||||
;; FIXME: store relative path in db
|
||||
file (cond
|
||||
(and electron-local-repo?
|
||||
util/win32?
|
||||
|
@ -146,6 +146,9 @@
|
|||
(not= "/" (first file))))
|
||||
(str (config/get-repo-dir repo-url) "/" file)
|
||||
|
||||
(and (mobile/is-native-platform?) (not= "/" (first file)))
|
||||
(str (config/get-repo-dir repo-url) "/" file)
|
||||
|
||||
:else
|
||||
file)
|
||||
new? (nil? (db/entity [:file/path file]))]
|
||||
|
|
Loading…
Reference in New Issue