From c5bdc7f1eb3ff4287beeeebb17d4f02f376a8d38 Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Fri, 28 Aug 2026 17:34:19 +0800
Subject: [PATCH] feat: add quick search tag filtering

---
 C1.source/Apptag/TagNavigationView.swift |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/C1.source/Apptag/TagNavigationView.swift b/C1.source/Apptag/TagNavigationView.swift
index 551eaa1..5cc3871 100644
--- a/C1.source/Apptag/TagNavigationView.swift
+++ b/C1.source/Apptag/TagNavigationView.swift
@@ -209,7 +209,7 @@
     ) {
         let oldNames = self.items.map(\.name)
         let newNames = items.map(\.name)
-        let needsRebuild = Set(oldNames) != Set(newNames) || self.orientation != orientation
+        let needsRebuild = oldNames.count != newNames.count || Set(oldNames) != Set(newNames) || self.orientation != orientation
         self.items = items
         self.orientation = orientation
         self.contentInsets = contentInsets
@@ -292,9 +292,14 @@
     }
 
     private func reuseButtonsInCurrentOrder() {
-        let existing = Dictionary(uniqueKeysWithValues: buttons.map { ($0.itemName, $0) })
+        var existing: [String: [TagNavigationButton]] = [:]
+        for button in buttons {
+            existing[button.itemName, default: []].append(button)
+        }
         buttons = items.compactMap { item in
-            guard let button = existing[item.name] else { return nil }
+            guard var candidates = existing[item.name], !candidates.isEmpty else { return nil }
+            let button = candidates.removeFirst()
+            existing[item.name] = candidates
             button.configure(item: item, orientation: orientation)
             button.refreshAppDropRegistration()
             return button

--
Gitblit v1.9.3