fix: nfs diffs

This commit is contained in:
Tienson Qin
2020-12-02 21:12:28 +08:00
parent 5563b1c28c
commit f0c0e44628
9 changed files with 47 additions and 51 deletions

View File

@@ -1140,23 +1140,13 @@ pre {
margin: 1em 0 0.5em;
}
/* .page .content *, #intro .content *, .page .title { */
/* margin-left: auto; */
/* margin-right: auto; */
/* } */
/* .page .blocks-container .ls-block { */
/* align-self: center; */
/* } */
#intro .content {
flex-direction: column;
align-items: center;
}
#intro .content :not(img), .foldable-title {
max-width: 665px;
.ls-block, .foldable-title {
max-width: 700px;
}
.ls-block, .editor-wrapper {
@@ -1172,10 +1162,6 @@ img, video {
margin-right: auto;
}
#intro .intro-docs, img, video, .intro .ls-block {
max-width: 653px;
}
.ls-block img {
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, .1), 0 10px 10px -5px rgba(0, 0, 0, .04);
}

View File

@@ -1076,8 +1076,7 @@
[:div.flex-1.flex-col.relative.block-content
(cond-> {:id (str "block-content-" uuid)
:style {:cursor "text"
:min-height 24
:max-width 560}}
:min-height 24}}
(not slide?)
(merge attrs))

View File

@@ -10,6 +10,7 @@
[frontend.state :as state]
[clojure.string :as string]
[frontend.ui :as ui]
[frontend.config :as config]
[frontend.components.content :as content]
[frontend.components.block :as block]
[frontend.components.editor :as editor]
@@ -68,6 +69,7 @@
today? (= (string/lower-case title)
(string/lower-case (date/journal-name)))
intro? (and (not (state/logged?))
(not (config/local-db? repo))
today?)]
[:div.flex-1.journal.page {:class (if intro? "intro" "")}
(ui/foldable

View File

@@ -70,7 +70,8 @@
(when-not (= repo config/local-repo)
(if (config/local-db? repo)
[:a.ml-2.mr-1.opacity-70.hover:opacity-100
{:on-click #(nfs-handler/refresh! repo)}
{:on-click #(nfs-handler/refresh! repo)
:title (str "Sync files with the local directory: " (config/get-local-dir repo))}
svg/refresh]
(let [changed-files (state/sub [:repo/changed-files repo])
should-push? (seq changed-files)

View File

@@ -18,7 +18,7 @@
.cp__sidebar-main-content {
padding: 3rem 1.5rem;
margin: 0 auto;
max-width: 640px;
max-width: 700px;
}
@media (max-width: 640px) {

View File

@@ -1501,21 +1501,23 @@
(defn extract-all-blocks-pages
[repo-url files]
(let [result (->> files
(map
(fn [{:file/keys [path content]} contents]
(println "Parsing : " path)
(when content
(let [utf8-content (utf8/encode content)]
(extract-blocks-pages repo-url path content utf8-content)))))
(remove empty?))
[pages block-ids blocks] (apply map concat result)
block-ids-set (set block-ids)
blocks (map (fn [b]
(-> b
(update :block/ref-blocks #(set/intersection (set %) block-ids-set))
(update :block/embed-blocks #(set/intersection (set %) block-ids-set)))) blocks)]
(apply concat [pages block-ids blocks])))
(when (seq files)
(let [result (->> files
(map
(fn [{:file/keys [path content]} contents]
(println "Parsing : " path)
(when content
(let [utf8-content (utf8/encode content)]
(extract-blocks-pages repo-url path content utf8-content)))))
(remove empty?))]
(when (seq result)
(let [[pages block-ids blocks] (apply map concat result)
block-ids-set (set block-ids)
blocks (map (fn [b]
(-> b
(update :block/ref-blocks #(set/intersection (set %) block-ids-set))
(update :block/embed-blocks #(set/intersection (set %) block-ids-set)))) blocks)]
(apply concat [pages block-ids blocks]))))))
;; TODO: compare blocks
(defn reset-file!

View File

@@ -326,7 +326,7 @@ title: How to take dummy notes?
:dark "Dark"
:remove-background "Remove background"
:open "Open"
:open-a-directory "Open a directory"}
:open-a-directory "Open a local directory"}
:fr {:help/about "A propos de Logseq"
:help/bug "Signaler une anomalie"
@@ -774,8 +774,8 @@ title: How to take dummy notes?
:white "亮色"
:dark "暗黑"
:remove-background "去除背景"
:open "导入"
:open-a-directory "导入本地文件夹"}
:open "打开"
:open-a-directory "打开本地文件夹"}
:zh-Hant {:on-boarding/title "你好,歡迎使用 Logseq"
:on-boarding/sharing "分享"

View File

@@ -27,7 +27,8 @@
(js/setInterval (fn []
(state/set-today! (date/today))
(when-let [repo (state/get-current-repo)]
(when (db/cloned? repo)
(when (or (db/cloned? repo)
(config/local-db? repo))
(let [today-page (string/lower-case (date/today))]
(when (empty? (db/get-page-blocks-no-cache repo today-page))
(repo-handler/create-today-journal-if-not-exists repo))))))

View File

@@ -163,10 +163,6 @@
{:keys [added modified deleted] :as diffs} (compute-diffs old-files new-files)
;; Use the same labels as isomorphic-git
rename-f (fn [typ col] (mapv (fn [file] {:type typ :path file}) col))
diffs (concat
(rename-f "remove" deleted)
(rename-f "add" added)
(rename-f "modify" modified))
_ (when (seq deleted)
(p/all (map #(idb/remove-item! (str handle-path %)) deleted)))
added-or-modified (set (concat added modified))
@@ -179,16 +175,25 @@
(p/let [content (.text (:file/file file))]
(assoc file :file/content content)))) added-or-modified))
(p/then (fn [result]
(let [files (->> (map #(dissoc % :file/file :file/handle) result)
(remove
(fn [file]
(let [content (:file/content file)
old-content (:file/content (get-file-f (:file/path file) old-files))]
(= content old-content)))))]
(when (and (seq diffs) (seq files))
(let [files (map #(dissoc % :file/file :file/handle) result)
non-modified? (fn [file]
(let [content (:file/content file)
old-content (:file/content (get-file-f (:file/path file) old-files))]
(= content old-content)))
non-modified-files (->> (filter non-modified? files)
(map :file/path))
modified-files (remove non-modified? files)
modified (set/difference (set modified) (set non-modified-files))
diffs (concat
(rename-f "remove" deleted)
(rename-f "add" added)
(rename-f "modify" modified))]
(when (or (and (seq diffs) (seq modified-files))
(seq diffs) ; delete
)
(repo-handler/load-repo-to-db! repo
{:diffs diffs
:nfs-files files})))))
:nfs-files modified-files})))))
(p/catch (fn [error]
(log/error :nfs/load-files-error error))))))))