From 55b6df0ae4adb34e490a761885f5338d99ede447 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 14 Mar 2024 16:16:33 +0100 Subject: [PATCH] :bug: Make opacity override same color recent-color --- common/src/app/common/files/changes.cljc | 14 +++++++++----- common/src/app/common/types/color.cljc | 6 ++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/common/src/app/common/files/changes.cljc b/common/src/app/common/files/changes.cljc index c200749d8a..978cc8edf3 100644 --- a/common/src/app/common/files/changes.cljc +++ b/common/src/app/common/files/changes.cljc @@ -609,11 +609,15 @@ (defmethod process-change :add-recent-color [data {:keys [color]}] ;; Moves the color to the top of the list and then truncates up to 15 - (update data :recent-colors (fn [rc] - (let [rc (conj (filterv (comp not #{color}) (or rc [])) color)] - (if (> (count rc) 15) - (subvec rc 1) - rc))))) + (update + data + :recent-colors + (fn [rc] + (let [rc (->> rc (d/removev (partial ctc/eq-recent-color? color))) + rc (-> rc (conj color))] + (cond-> rc + (> (count rc) 15) + (subvec 1)))))) ;; -- Media diff --git a/common/src/app/common/types/color.cljc b/common/src/app/common/types/color.cljc index 382530ac2a..7bded14921 100644 --- a/common/src/app/common/types/color.cljc +++ b/common/src/app/common/types/color.cljc @@ -358,3 +358,9 @@ (process-shape-colors shape sync-color))) +(defn eq-recent-color? + [c1 c2] + (or (= c1 c2) + (and (some? (:color c1)) + (some? (:color c2)) + (= (:color c1) (:color c2)))))