From ca9fe31f8da516dcb0172fa36fb187c810e42dfa Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Fri, 11 Oct 2024 11:57:25 +0200 Subject: [PATCH 1/2] obtain matches sort rank for filtering guides --- src/components/platformFilter/index.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/platformFilter/index.tsx b/src/components/platformFilter/index.tsx index d578299f50660..e4a7967e19ac0 100644 --- a/src/components/platformFilter/index.tsx +++ b/src/components/platformFilter/index.tsx @@ -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 (
From 115e2dad80a1f1ecb749132a4eb59925247b2dcb Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Wed, 16 Oct 2024 11:50:48 +0200 Subject: [PATCH 2/2] preserve match sort order for guides in platform selector --- src/components/platformSelector/index.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/platformSelector/index.tsx b/src/components/platformSelector/index.tsx index f67b5043a61f6..7762181c9950d 100644 --- a/src/components/platformSelector/index.tsx +++ b/src/components/platformSelector/index.tsx @@ -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)