fix(mobile): refresh

pull/3360/head
Tienson Qin 2021-11-27 17:46:32 +08:00
parent 7101b8c491
commit d0d25b5ad4
6 changed files with 80 additions and 60 deletions

View File

@ -11,5 +11,9 @@
"splashImmersive": true,
"backgroundColor": "#002b36"
}
},
"server": {
"url": "http://192.168.1.59:3001",
"cleartext": true
}
}

View File

@ -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;

View File

@ -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]

View File

@ -20,10 +20,17 @@
(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 []
(p/let [result (p/loop [result []
dirs [path]]
(if (empty? dirs)
result
@ -33,11 +40,12 @@
js->clj
(get "files" []))
files (->> files
(remove (fn [file] (string/starts-with? file "."))))
(remove (fn [file]
(or (string/starts-with? file ".")
(= file "bak")))))
files (->> files
(map (fn [file] (futil/node-path.join d file))))
_ (prn "files: ")
_ (js/console.dir files)
(map (fn [file]
(futil/node-path.join d file))))
files-with-stats (p/all
(mapv
(fn [file]
@ -72,12 +80,13 @@
:data
#(assoc file-result :content %))))))]
(p/recur (concat result files-result)
(concat (rest dirs) files-dir))))))
(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]

View File

@ -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)

View File

@ -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]))]