fix: dock normalize dedupes ids and trims labels
Co-Authored-By: Ovis Fast (Claude) <[email protected]>
This commit is contained in:
1 parent
6b1f946d25
commit
3b457aad1c
2 files changed
+16
-2
No files matched your search
@@ -54,6 +54,7 @@ export function normalize(raw) {
|
||||
/** @type {DockButton[]} */
|
||||
const out = [];
|
||||
const seen = new Set();
|
||||
const ids = new Set();
|
||||
for (const item of raw) {
|
||||
if (out.length >= DOCK_LIMIT) break;
|
||||
if (!item || typeof item !== "object" || Array.isArray(item)) continue;
|
||||
@@ -62,11 +63,12 @@ export function normalize(raw) {
|
||||
if (typeof text !== "string" || text.trim() === "") continue;
|
||||
if (typeof mode !== "string" || !MODES.has(mode)) continue;
|
||||
const key = text.trim();
|
||||
if (seen.has(key)) continue;
|
||||
if (seen.has(key) || ids.has(id)) continue;
|
||||
seen.add(key);
|
||||
ids.add(id);
|
||||
out.push({
|
||||
id,
|
||||
label: typeof label === "string" && label.trim() !== "" ? label : defaultLabel(text),
|
||||
label: typeof label === "string" && label.trim() !== "" ? label.trim() : defaultLabel(text),
|
||||
text,
|
||||
mode: /** @type {"send"|"insert"} */ (mode),
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user