Skip to content

Commit

Permalink
fix: Update sorting order for guides on platform filter (#11547)
Browse files Browse the repository at this point in the history
  • Loading branch information
chargome authored Oct 16, 2024
1 parent 53c5a63 commit 12b6f30
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/components/platformFilter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ export function PlatformFilter({platforms}: {platforms: Platform[]}) {
uniqByReference(matches.map(x => (x.type === 'platform' ? x : x.platform))).map(p => {
return {
...p,
guides: p.guides.filter(g => matches.some(m => m.key === g.key)),
guides: matches
.filter(m => m.type === 'guide' && m.platform.key === p.key)
.map(m => p.guides.find(g => g.key === m.key)!)
.filter(Boolean),
integrations: p.integrations.filter(i => matches.some(m => m.key === i.key)),
};
})
);

return (
<div>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 py-8 md:items-end">
Expand Down
12 changes: 9 additions & 3 deletions src/components/platformSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,15 @@ export function PlatformSelector({
platform={{
...platform,
// only keep guides that are in the matches list
guides: platform.guides.filter(g =>
matches.some(m => m.key === g.key)
),
guides: platform.guides
.filter(g =>
matches.some(m => m.key === g.key && m.type === 'guide')
)
.sort((a, b) => {
const indexA = matches.findIndex(m => m.key === a.key);
const indexB = matches.findIndex(m => m.key === b.key);
return indexA - indexB;
}),

integrations: platform.integrations.filter(i =>
matches.some(m => m.key === i.key)
Expand Down

0 comments on commit 12b6f30

Please sign in to comment.