File tree Expand file tree Collapse file tree 1 file changed +11
-21
lines changed
packages/view/src/components/FilteredAuthors Expand file tree Collapse file tree 1 file changed +11
-21
lines changed Original file line number Diff line number Diff line change @@ -10,33 +10,23 @@ const FilteredAuthors = () => {
1010 const authSrcMap = usePreLoadAuthorImg ( ) ;
1111 const selectedClusters = getInitData ( selectedData ) ;
1212
13- // 이미 선택된 사용자를 관리
14- const addedAuthors = new Set ( ) ;
13+ // 2차원 authorNames를 평탄화하고 중복 제거
14+ const uniqueAuthorNames = Array . from (
15+ new Set ( selectedClusters . flatMap ( ( cluster ) => cluster . summary . authorNames . flat ( ) ) )
16+ ) ;
1517
1618 return (
1719 < div className = "filtered-authors" >
1820 < p className = "filtered-authors__label" > Authors:</ p >
1921 < div className = "filtered-authors__author" >
2022 { authSrcMap &&
21- selectedClusters . map ( ( selectedCluster ) => {
22- return selectedCluster . summary . authorNames . map ( ( authorArray : string [ ] ) => {
23- return authorArray . map ( ( authorName : string ) => {
24- // 이미 추가된 사용자인지 확인 후 추가되지 않은 경우에만 추가하고 Set에 이름을 저장
25- if ( ! addedAuthors . has ( authorName ) ) {
26- addedAuthors . add ( authorName ) ;
27- return (
28- < Author
29- key = { authorName }
30- name = { authorName }
31- src = { authSrcMap [ authorName ] }
32- />
33- ) ;
34- }
35- // 이미 추가된 사용자인 경우 null 반환
36- return null ;
37- } ) ;
38- } ) ;
39- } ) }
23+ uniqueAuthorNames . map ( ( authorName ) => (
24+ < Author
25+ key = { authorName }
26+ name = { authorName }
27+ src = { authSrcMap [ authorName ] }
28+ />
29+ ) ) }
4030 </ div >
4131 </ div >
4232 ) ;
You can’t perform that action at this time.
0 commit comments