From 3c1086dfccfde0aac60c3c93898021474bea5b1f Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 10 Jun 2024 18:50:50 +0200 Subject: [PATCH 1/3] :bug: Fix race condition between shape modifiation and persistence --- frontend/src/app/main/data/changes.cljs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/main/data/changes.cljs b/frontend/src/app/main/data/changes.cljs index 4da8d30da..6c0b3d753 100644 --- a/frontend/src/app/main/data/changes.cljs +++ b/frontend/src/app/main/data/changes.cljs @@ -69,9 +69,10 @@ (cpc/check-changes! undo-changes))) (let [commit-id (or commit-id (uuid/next)) + source (d/nilv source :local) commit {:id commit-id :created-at (dt/now) - :source (d/nilv source :local) + :source source :origin (ptk/type origin) :features features :file-id file-id From e4e56828f6488cc96dd1caee0514fb91d186904c Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 10 Jun 2024 18:56:59 +0200 Subject: [PATCH 2/3] :lipstick: Fix internal naming for make code more self-explanatory --- frontend/src/app/main/data/persistence.cljs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/main/data/persistence.cljs b/frontend/src/app/main/data/persistence.cljs index 452340176..08a0719b3 100644 --- a/frontend/src/app/main/data/persistence.cljs +++ b/frontend/src/app/main/data/persistence.cljs @@ -182,7 +182,7 @@ (log/debug :hint "initialize persistence") (let [stoper-s (rx/filter (ptk/type? ::initialize-persistence) stream) - commits-s + local-commits-s (->> stream (rx/filter dch/commit?) (rx/map deref) @@ -192,20 +192,20 @@ notifier-s (rx/merge - (->> commits-s + (->> local-commits-s (rx/debounce 3000) (rx/tap #(log/trc :hint "persistence beat"))) (->> stream (rx/filter #(= % ::force-persist))))] (rx/merge - (->> commits-s + (->> local-commits-s (rx/debounce 200) (rx/map (fn [_] (update-status :pending))) (rx/take-until stoper-s)) - (->> commits-s + (->> local-commits-s (rx/buffer-time 200) (rx/mapcat merge-commit) (rx/map dch/update-indexes) @@ -216,7 +216,7 @@ ;; Here we watch for local commits, buffer them in a small ;; chunks (very near in time commits) and append them to the ;; persistence queue - (->> commits-s + (->> local-commits-s (rx/buffer-until notifier-s) (rx/mapcat merge-commit) (rx/map append-commit) From d35569dc55b53be53885f91653b47babec48487d Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 10 Jun 2024 18:59:39 +0200 Subject: [PATCH 3/3] :sparkles: Simplify transducer definition for proces redo changes --- frontend/src/app/main/data/changes.cljs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/frontend/src/app/main/data/changes.cljs b/frontend/src/app/main/data/changes.cljs index 6c0b3d753..d16cfafc5 100644 --- a/frontend/src/app/main/data/changes.cljs +++ b/frontend/src/app/main/data/changes.cljs @@ -111,9 +111,7 @@ redo-changes (if pending (into redo-changes - (comp - (map :redo-changes) - (mapcat identity)) + (mapcat :redo-changes) pending) redo-changes)]