fix(sync): push immediately after the page was deleted or renamed

This commit is contained in:
Tienson Qin
2020-11-03 14:55:14 +08:00
parent d8dc16704e
commit 3197b784fd
3 changed files with 34 additions and 18 deletions

View File

@@ -283,8 +283,8 @@
(reset! last-child-end-pos old-end-pos)))
(cond->
{:block/uuid uuid
:block/meta new-meta}
{:block/uuid uuid
:block/meta new-meta}
(and (some? indent-left?) (not @next-leq-level?))
(assoc :block/level (if indent-left? (dec level) (inc level)))
(and new-content (not @next-leq-level?))
@@ -401,9 +401,9 @@
(util/->tags tags))
page-alias (when-let [alias (:alias new-properties)]
(map
(fn [alias]
{:page/name (string/lower-case alias)})
(remove #{(:page/name page)} alias)))
(fn [alias]
{:page/name (string/lower-case alias)})
(remove #{(:page/name page)} alias)))
permalink-changed? (when (and pre-block? (:permalink old-properties))
(not= (:permalink old-properties)
(:permalink new-properties)))
@@ -423,7 +423,8 @@
:else
value)]
(when (not= (string/trim content) (string/trim value)) ; block content changed
(cond
(not= (string/trim content) (string/trim value)) ; block content changed
(let [file (db/entity repo (:db/id file))]
(cond
;; Page was referenced but no related file
@@ -505,10 +506,10 @@
[[:db/retract page-id :page/properties]]))
pages (if (seq page-tags)
(let [tag-pages (map
(fn [page]
{:page/original-name page
:page/name page})
(map :tag/name page-tags))]
(fn [page]
{:page/original-name page
:page/name page})
(map :tag/name page-tags))]
(concat pages tag-pages))
pages)
page-tags (when (and pre-block? (seq page-tags))
@@ -546,10 +547,17 @@
(ui-handler/re-render-root!))
(when (state/git-auto-push?)
(repo-handler/push repo nil)))
(repo-handler/push repo nil)))
:else
nil))))))
nil))
(seq (state/get-changed-files))
(when (state/git-auto-push?)
(repo-handler/push repo nil))
:else
nil))))
(defn insert-new-block-aux!
[{:block/keys [uuid content meta file dummy? level repo page format properties collapsed?] :as block}
@@ -1007,7 +1015,9 @@
(when top-block?
(route-handler/redirect! {:to :page
:path-params {:name (:page/name page)}})
(ui-handler/re-render-root!))))))
(ui-handler/re-render-root!))
(when (state/git-auto-push?)
(repo-handler/push repo nil))))))
(defn remove-block-property!
[block-id key]
@@ -1099,7 +1109,7 @@
;; (when e
;; (when-not (util/input? (gobj/get e "target"))
;; (util/clear-selection!)))
)
)
(defn clear-selection-blocks!
[]
@@ -1751,7 +1761,7 @@
:end-pos end-pos}))]
(reset! last-start-pos end-pos)
block))
blocks))
blocks))
file-id (:db/id (:block/file block))
file (db/entity file-id)
page (:block/page block)
@@ -1815,7 +1825,7 @@
:end-pos end-pos}))]
(reset! last-start-pos end-pos)
block))
blocks))
blocks))
file-id (:db/id (:block/file block))
file (db/entity file-id)
page (:block/page block)