From 0c8e0ed3dd8b54f63b24b56e9d60f79cbbe4e021 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 9 Jul 2021 14:50:57 +0200 Subject: [PATCH 1/5] :bug: Fix problem with invalid svg value --- frontend/src/app/util/svg.cljs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/util/svg.cljs b/frontend/src/app/util/svg.cljs index 48e64746e..b4d3a352a 100644 --- a/frontend/src/app/util/svg.cljs +++ b/frontend/src/app/util/svg.cljs @@ -488,8 +488,9 @@ filter-values))) (defn extract-ids [val] - (->> (re-seq xml-id-regex val) - (mapv second))) + (when (some? val) + (->> (re-seq xml-id-regex val) + (mapv second)))) (defn fix-dot-number "Fixes decimal numbers starting in dot but without leading 0" From 5126c85623073a1a07f9fa2a4adb42a89aab8cdc Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 15 Jul 2021 11:57:15 +0200 Subject: [PATCH 2/5] :bug: Properly handle path with fill-image on file media gc task. --- backend/src/app/tasks/file_media_gc.clj | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/backend/src/app/tasks/file_media_gc.clj b/backend/src/app/tasks/file_media_gc.clj index bc1675447..aedcbc78b 100644 --- a/backend/src/app/tasks/file_media_gc.clj +++ b/backend/src/app/tasks/file_media_gc.clj @@ -64,16 +64,21 @@ (comp (map :objects) (mapcat vals) - (filter #(= :image (:type %))) - (map :metadata) - (map :id))) + (map (fn [{:keys [type] :as obj}] + (case type + :path (get-in obj [:fill-image :id]) + :image (get-in obj [:metadata :id]) + nil))) + (filter uuid?))) (defn- collect-used-media [data] + (let [pages (concat + (vals (:pages-index data)) + (vals (:components data)))] (-> #{} - (into collect-media-xf (vals (:pages-index data))) - (into collect-media-xf (vals (:components data))) - (into (keys (:media data))))) + (into collect-media-xf pages) + (into (keys (:media data)))))) (defn- process-file [{:keys [conn] :as cfg} {:keys [id data age] :as file}] From 899dc5b680ba29f690c50f887b43da0c484aca0b Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 15 Jul 2021 11:57:45 +0200 Subject: [PATCH 3/5] :bug: Properly dissoc :metadata prop on image->path conversion. --- frontend/src/app/util/path/shapes_to_path.cljs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/util/path/shapes_to_path.cljs b/frontend/src/app/util/path/shapes_to_path.cljs index 0fb979bb1..8d7c86cbd 100644 --- a/frontend/src/app/util/path/shapes_to_path.cljs +++ b/frontend/src/app/util/path/shapes_to_path.cljs @@ -139,8 +139,8 @@ (d/without-keys dissoc-attrs) (assoc :type :path) (assoc :content new-content) - (cond-> (= :image type) - (assoc :fill-image metadata)))) + (cond-> (= :image type) (-> (assoc :fill-image metadata) + (dissoc :metadata))))) ;; Do nothing if the shape is not of a correct type shape)) From 7efc1a0366cd26622d849468b90828a252959332 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 15 Jul 2021 13:20:12 +0200 Subject: [PATCH 4/5] :bug: Fix problem with undo operation and children order --- common/src/app/common/pages/helpers.cljc | 3 ++- frontend/src/app/main/data/workspace/common.cljs | 12 ++++++++---- frontend/src/app/main/data/workspace/undo.cljs | 5 ++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/common/src/app/common/pages/helpers.cljc b/common/src/app/common/pages/helpers.cljc index 2c7507243..37d7febee 100644 --- a/common/src/app/common/pages/helpers.cljc +++ b/common/src/app/common/pages/helpers.cljc @@ -99,7 +99,8 @@ ;; Implemented with transient for performance (defn get-children - "Retrieve all children ids recursively for a given object" + "Retrieve all children ids recursively for a given object. The + children's order will be breadth first." [id objects] (loop [result (transient []) diff --git a/frontend/src/app/main/data/workspace/common.cljs b/frontend/src/app/main/data/workspace/common.cljs index 75e9ce724..5d6d7c00f 100644 --- a/frontend/src/app/main/data/workspace/common.cljs +++ b/frontend/src/app/main/data/workspace/common.cljs @@ -350,6 +350,8 @@ (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) + ids (cp/clean-loops objects ids) + groups-to-unmask (reduce (fn [group-ids id] ;; When the shape to delete is the mask of a masked group, @@ -387,10 +389,12 @@ ids) all-children - (reduce (fn [res id] - (into res (cp/get-children id objects))) - (d/ordered-set) - ids) + (->> ids + (reduce (fn [res id] + (into res (cp/get-children id objects))) + []) + (reverse) + (into (d/ordered-set))) empty-parents (into (d/ordered-set) empty-parents-xform all-parents) diff --git a/frontend/src/app/main/data/workspace/undo.cljs b/frontend/src/app/main/data/workspace/undo.cljs index 85651e0d8..dd2ded3ce 100644 --- a/frontend/src/app/main/data/workspace/undo.cljs +++ b/frontend/src/app/main/data/workspace/undo.cljs @@ -6,7 +6,6 @@ (ns app.main.data.workspace.undo (:require - [app.common.pages :as cp] [app.common.pages.spec :as spec] [app.common.spec :as us] [cljs.spec.alpha :as s] @@ -31,13 +30,13 @@ (subvec undo (- cnt MAX-UNDO-SIZE)) undo))) +;; TODO: Review the necessity of this method (defn materialize-undo - [changes index] + [_changes index] (ptk/reify ::materialize-undo ptk/UpdateEvent (update [_ state] (-> state - (update :workspace-data cp/process-changes changes) (assoc-in [:workspace-undo :index] index))))) (defn- add-undo-entry From 17ae6bf89dc46ff55d106fd182a278b0f08b6d18 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 15 Jul 2021 13:48:42 +0200 Subject: [PATCH 5/5] :bug: Fix problem when page deletion and undo. Related to duplicated page reference in undo page deletion. --- common/src/app/common/pages/changes.cljc | 33 ++++++++++--------- .../src/app/main/data/workspace/changes.cljs | 5 +++ 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/common/src/app/common/pages/changes.cljc b/common/src/app/common/pages/changes.cljc index e3a5274f2..1172de76e 100644 --- a/common/src/app/common/pages/changes.cljc +++ b/common/src/app/common/pages/changes.cljc @@ -293,23 +293,24 @@ (defmethod process-change :add-page [data {:keys [id name page]}] - (cond - (and (string? name) (uuid? id)) - (let [page (assoc init/empty-page-data - :id id - :name name)] - (-> data - (update :pages conj id) - (update :pages-index assoc id page))) - - (map? page) - (-> data - (update :pages conj (:id page)) - (update :pages-index assoc (:id page) page)) - - :else + (when (and id name page) (ex/raise :type :conflict - :hint "name or page should be provided, never both"))) + :hint "name or page should be provided, never both")) + (letfn [(conj-if-not-exists [pages id] + (cond-> pages + (not (d/seek #(= % id) pages)) + (conj id)))] + (if (and (string? name) (uuid? id)) + (let [page (assoc init/empty-page-data + :id id + :name name)] + (-> data + (update :pages conj-if-not-exists id) + (update :pages-index assoc id page))) + + (-> data + (update :pages conj-if-not-exists (:id page)) + (update :pages-index assoc (:id page) page))))) (defmethod process-change :mod-page [data {:keys [id name]}] diff --git a/frontend/src/app/main/data/workspace/changes.cljs b/frontend/src/app/main/data/workspace/changes.cljs index 4ca6c4f0b..4edfa71fd 100644 --- a/frontend/src/app/main/data/workspace/changes.cljs +++ b/frontend/src/app/main/data/workspace/changes.cljs @@ -141,6 +141,11 @@ (try (us/assert ::spec/changes redo-changes) (us/assert ::spec/changes undo-changes) + + ;; (prn "====== commit-changes ======" path) + ;; (cljs.pprint/pprint redo-changes) + ;; (cljs.pprint/pprint undo-changes) + (update-in state path cp/process-changes redo-changes false) (catch :default e