Skip to content

Commit

Permalink
fix:사용자 중복되지 않게 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
HIITMEMARIO committed Aug 1, 2024
1 parent eaa53cb commit 698832b
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions packages/view/src/components/FilteredAuthors/FilteredAuthors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,35 @@ const FilteredAuthors = () => {
const authSrcMap = usePreLoadAuthorImg();
const selectedClusters = getInitData(selectedData);
const filteredSelectedData = selectedClusters.reverse().slice(0, 9);
const selectedClustersLength = selectedClusters.slice(9);

const selectedClustersLength = selectedClusters.length - filteredSelectedData.length;

// 이미 선택된 사용자를 관리
const addedAuthors = new Set();

return (
<div className="selected-container">
{authSrcMap &&
filteredSelectedData.reverse().map((selectedCluster) => {
return selectedCluster.summary.authorNames.map((authorArray: string[]) => {
return authorArray.map((authorName: string) => (
<Author
key={authorName}
name={authorName}
src={authSrcMap[authorName]}
/>
));
return authorArray.map((authorName: string) => {
// 이미 추가된 사용자인지 확인 후 추가되지 않은 경우에만 추가하고 Set에 이름을 저장
if (!addedAuthors.has(authorName)) {
addedAuthors.add(authorName);
return (
<Author
key={authorName}
name={authorName}
src={authSrcMap[authorName]}
/>
);
}
// 이미 추가된 사용자인 경우 null 반환
return null;
});
});
})}
<div className="selected-length">
{selectedClusters.length > 9 ? `+ ${selectedClustersLength.length} more` : null}
</div>
<div className="selected-length">{selectedClusters.length > 9 ? `+ ${selectedClustersLength} more` : null}</div>
</div>
);
};
Expand Down

0 comments on commit 698832b

Please sign in to comment.