From 9cfc00ce973a7149771bcd71555a64c3a231c422 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Thu, 4 Jan 2024 11:48:53 +0100 Subject: [PATCH] :bug: Fix remap colors on binary import --- backend/src/app/rpc/commands/binfile.clj | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/backend/src/app/rpc/commands/binfile.clj b/backend/src/app/rpc/commands/binfile.clj index 7e7327b32..e3015c023 100644 --- a/backend/src/app/rpc/commands/binfile.clj +++ b/backend/src/app/rpc/commands/binfile.clj @@ -593,6 +593,7 @@ (declare lookup-index) (declare update-index) (declare relink-media) +(declare relink-colors) (declare relink-shapes) (defmulti read-import ::version) @@ -723,6 +724,7 @@ (update :pages-index relink-shapes) (update :components relink-shapes) (update :media relink-media) + (update :colors relink-colors) (d/without-nils)))))) @@ -997,6 +999,17 @@ media media)) +(defn- relink-colors + "A function responsible of process the :colors attr of file data and + remap the old ids with the new ones." + [colors] + (reduce-kv (fn [res k v] + (if (:image v) + (update-in res [k :image :id] lookup-index) + res)) + colors + colors)) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; HIGH LEVEL API ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;