From 1ebbf1ddf417dfa67a985da60fe9f427ef21ccd5 Mon Sep 17 00:00:00 2001 From: scheinriese Date: Tue, 19 May 2026 13:55:25 +0200 Subject: [PATCH] fix(icon): correct ordering of dedup + cap in add-used-item! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pipeline ran (take 24) BEFORE (filter should-keep?), so an existing duplicate at position 24+ in the recents list was truncated unfiltered instead of caught by the dedup. Then (cons normalized) prepended the new pick, producing 25 items — both violating the 24-item cap and failing to actually move the dup to the front. Reorder: filter across the whole existing list, cons the new pick, THEN cap at 24. REPL-verified on a 27-item list with the duplicate at index 24: old pipeline stored 25 items (cap violated), new pipeline stored 24 (cap honored, dup correctly displaced by the cons). Co-Authored-By: Claude Opus 4.7 --- src/main/frontend/components/icon.cljs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/frontend/components/icon.cljs b/src/main/frontend/components/icon.cljs index 9c5d790640..0b653e6858 100644 --- a/src/main/frontend/components/icon.cljs +++ b/src/main/frontend/components/icon.cljs @@ -2260,10 +2260,13 @@ (not= (:type item) new-type) ;; Remove exact duplicates for other types (not= normalized item))) + ;; Filter dupes across the WHOLE existing list, not just the first 24 + ;; — otherwise an existing duplicate beyond position 24 stays in storage + ;; on the next call. Then cons the new pick and cap at 24. s (some->> (or (get-used-items) []) - (take 24) (filter should-keep?) - (cons normalized))] + (cons normalized) + (take 24))] (storage/set :ui/ls-icons-used-v2 s))) (defn derive-initials