Skip to content

Commit

Permalink
Merge pull request #1903 from ResearchHub/fix/comment-count
Browse files Browse the repository at this point in the history
Fix: display hubs used for reputation first to match homepage
  • Loading branch information
yattias authored Jan 8, 2025
2 parents 9232b6a + 9c0e36d commit 2e3401e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions components/Document/lib/DocumentHubs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ const DocumentHubs = ({
numOfVisibleHubs?: number;
}) => {
const [showMore, setShowMore] = useState<boolean>(false);
const sortedHubs = hubs.sort((a, b) => {
return a.relevancyScore > b.relevancyScore ? -1 : 1;
});
let sortedHubs = hubs.filter((h) => h.isUsedForRep).concat(hubs.filter((h) => !h.isUsedForRep));

// If no hubs are used for rep, show all hubs.
if (sortedHubs.length === 0) {
sortedHubs = hubs;
}

const visibleHubs = showMore ? sortedHubs : sortedHubs.slice(0, numOfVisibleHubs);

return (
Expand Down

0 comments on commit 2e3401e

Please sign in to comment.