@@ -70,24 +70,26 @@ const ResponseTags = ({
7070 : true ;
7171
7272 // Dataset citation render items
73- const datasetCitationList = useMemo ( ( ) => {
74- // Keep first item per collectionId and preserve first-seen order
75- const firstByCollection = new Map < string , SearchDataResponseItemType > ( ) ;
76- quoteList . forEach ( ( cur ) => {
77- if ( ! firstByCollection . has ( cur . collectionId ) ) {
78- firstByCollection . set ( cur . collectionId , cur ) ;
79- }
80- } ) ;
81- return Array . from ( firstByCollection . values ( ) ) . map ( ( item ) => ( {
82- itemType : 'dataset' as const ,
83- sourceName : item . sourceName ,
84- sourceId : item . sourceId ,
85- icon : item . imageId
86- ? 'core/dataset/imageFill'
87- : getSourceNameIcon ( { sourceId : item . sourceId , sourceName : item . sourceName } ) ,
88- collectionId : item . collectionId ,
89- datasetId : item . datasetId
90- } ) ) ;
73+ const sourceList = useMemo ( ( ) => {
74+ return Object . values (
75+ quoteList . reduce ( ( acc : Record < string , SearchDataResponseItemType [ ] > , cur ) => {
76+ if ( ! acc [ cur . collectionId ] ) {
77+ acc [ cur . collectionId ] = [ cur ] ;
78+ }
79+ return acc ;
80+ } , { } )
81+ )
82+ . flat ( )
83+ . map ( ( item ) => ( {
84+ itemType : 'dataset' as const ,
85+ sourceName : item . sourceName ,
86+ sourceId : item . sourceId ,
87+ icon : item . imageId
88+ ? 'core/dataset/imageFill'
89+ : getSourceNameIcon ( { sourceId : item . sourceId , sourceName : item . sourceName } ) ,
90+ collectionId : item . collectionId ,
91+ datasetId : item . datasetId
92+ } ) ) ;
9193 } , [ quoteList ] ) ;
9294
9395 // Merge dataset citations and external link references for unified rendering
@@ -107,8 +109,8 @@ const ResponseTags = ({
107109 ...r ,
108110 itemType : 'link'
109111 } ) ) ;
110- return [ ...datasetCitationList , ...linkItems ] ;
111- } , [ datasetCitationList , externalLinkList ] ) ;
112+ return [ ...sourceList , ...linkItems ] ;
113+ } , [ sourceList , externalLinkList ] ) ;
112114
113115 const notEmptyTags = notSharePage || quoteList . length > 0 || ( isPc && durationSeconds > 0 ) ;
114116
0 commit comments