From 0014bb3d246a2e464850b8fabff13a9bbe027f6b Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 16 Feb 2021 13:46:31 +0100 Subject: [PATCH] :bug: Fix problem with indices refreshing on page changes --- CHANGES.md | 22 +++++++++---------- .../src/app/main/data/workspace/common.cljs | 22 ++++++++++++++++--- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 4487e3a75..e5ac238e5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,30 +1,28 @@ # CHANGELOG # -## Next +## :rocket: Next -### New features +### :sparkles: New features +- Add major refactor of internal pubsub/redis code; improves scalability and performance #640 - Add optional loki integration. - Bounce & Complaint handling. - Disable groups interactions when holding "Ctrl" key (deep selection) - New action in context menu to "edit" some shapes (binded to key "Enter") -- Add major refactor of internal pubsub/redis code; improves - scalability and performance #640 -### Bugs fixed +### :bug: Bugs fixed +- Add some missing database indexes (mainly improves performance on large databases on file-update rpc method, and some background tasks). +- Fix problem width handoff code generation [Taiga #1204](https://tree.taiga.io/project/penpot/issue/1204) +- Fix problem with indices refreshing on page changes [#646](https://github.com/penpot/penpot/issues/646) - Properly handle errors on github, gitlab and ldap auth backends. - Properly mark profile auth backend (on first register/ auth with 3rd party auth provider). -- Fix problem width handoff code generation [Taiga #1204](https://tree.taiga.io/project/penpot/issue/1204) -- Add some missing database indexes (mainly improves performance on - large databases on file-update rpc method, and some background - tasks). ## 1.2.0-alpha -### New features +### :sparkles: New features - Add horizontal/vertical flip - Add images lock proportions by default [#541](https://github.com/penpot/penpot/discussions/541), [#609](https://github.com/penpot/penpot/issues/609) @@ -37,7 +35,7 @@ - Fix behavior of select all command when there are objects outside frames [Taiga #1209](https://tree.taiga.io/project/penpot/issue/1209) -### Bugs fixed +### :bug: Bugs fixed - Fix 404 when access shared link [#615](https://github.com/penpot/penpot/issues/615) - Fix 500 when requestion password reset @@ -57,7 +55,7 @@ - Fix updates on collaborative editing not updating selection rectangles [Taiga #1127](https://tree.taiga.io/project/penpot/issue/1127) - Make the team deletion deferred (in the same way other objects) -### Community contributions by (Thank you! :heart:) +### :heart: Community contributions by (Thank you!) - abtinmo [#538](https://github.com/penpot/penpot/pull/538) - kdrag0n [#585](https://github.com/penpot/penpot/pull/585) diff --git a/frontend/src/app/main/data/workspace/common.cljs b/frontend/src/app/main/data/workspace/common.cljs index b4b8a128f..a83b4c68f 100644 --- a/frontend/src/app/main/data/workspace/common.cljs +++ b/frontend/src/app/main/data/workspace/common.cljs @@ -63,6 +63,8 @@ ;; --- Changes Handling +(defonce page-change? #{:add-page :mod-page :del-page :mov-page}) + (defn commit-changes ([changes undo-changes] (commit-changes changes undo-changes {})) @@ -105,10 +107,24 @@ ptk/WatchEvent (watch [_ state stream] (when-not @error - (let [page-id (:current-page-id state)] + (let [;; adds page-id to page changes (that have the `id` field instead) + add-page-id + (fn [{:keys [id type page] :as change}] + (cond-> change + (page-change? type) + (assoc :page-id (or id (:id page))))) + + changes-by-pages + (->> changes + (map add-page-id) + (remove #(nil? (:page-id %))) + (group-by :page-id)) + + process-page-changes + (fn [[page-id changes]] + (update-indices page-id changes))] (rx/concat - (when (some :page-id changes) - (rx/of (update-indices page-id changes))) + (rx/from (map process-page-changes changes-by-pages)) (when (and save-undo? (seq undo-changes)) (let [entry {:undo-changes undo-changes