Skip to content

Commit f417212

Browse files
Copilothotlong
andcommitted
refactor: use Set-based deduplication in RecordDetailView for consistency
Address code review: use the same O(n) Set-based dedup pattern as action-bar.tsx, wrapped in useMemo for React performance. Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 9fd3b5a commit f417212

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

apps/console/src/components/RecordDetailView.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,16 @@ export function RecordDetailView({ dataSource, objects, onEdit }: RecordDetailVi
387387
];
388388

389389
// Filter actions for record_header location and deduplicate by name
390-
const recordHeaderActions = (objectDef.actions || []).filter(
391-
(a: any) => a.locations?.includes('record_header'),
392-
).filter((a: any, i: number, arr: any[]) => arr.findIndex((b: any) => b.name === a.name) === i);
390+
const recordHeaderActions = useMemo(() => {
391+
const seen = new Set<string>();
392+
return (objectDef.actions || []).filter((a: any) => {
393+
if (!a.locations?.includes('record_header')) return false;
394+
if (!a.name) return true;
395+
if (seen.has(a.name)) return false;
396+
seen.add(a.name);
397+
return true;
398+
});
399+
}, [objectDef.actions]);
393400

394401
// Build highlightFields: prefer explicit config, fallback to auto-detect key fields
395402
const explicitHighlight: HighlightField[] | undefined = objectDef.views?.detail?.highlightFields;

0 commit comments

Comments
 (0)