👁️
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix issues with spread ordering and sorting

+18 -9
+1 -1
src/components/CardSpread.tsx
··· 9 9 } 10 10 11 11 export function CardSpread({ cardIds, emptyIcon }: CardSpreadProps) { 12 - const cards = cardIds.slice(-3); 12 + const cards = cardIds.slice(0, 3).reverse(); 13 13 14 14 if (cards.length === 0) { 15 15 return (
+6 -6
src/components/DeckPreview.tsx
··· 129 129 // Tiebreak 1: prefer cards whose name matches deck title 130 130 const aNameMatch = textMatchesDeckTitle(a.card?.name, deckWords); 131 131 const bNameMatch = textMatchesDeckTitle(b.card?.name, deckWords); 132 - if (aNameMatch && !bNameMatch) return 1; 133 - if (bNameMatch && !aNameMatch) return -1; 132 + if (aNameMatch && !bNameMatch) return -1; 133 + if (bNameMatch && !aNameMatch) return 1; 134 134 // Tiebreak 2: prefer cards whose type line matches deck title 135 135 const aTypeMatch = textMatchesDeckTitle(a.card?.type_line, deckWords); 136 136 const bTypeMatch = textMatchesDeckTitle(b.card?.type_line, deckWords); 137 - if (aTypeMatch && !bTypeMatch) return 1; 138 - if (bTypeMatch && !aTypeMatch) return -1; 137 + if (aTypeMatch && !bTypeMatch) return -1; 138 + if (bTypeMatch && !aTypeMatch) return 1; 139 139 // Tiebreak 3: prefer cards whose oracle text matches deck title 140 140 const aTextMatch = textMatchesDeckTitle(a.card?.oracle_text, deckWords); 141 141 const bTextMatch = textMatchesDeckTitle(b.card?.oracle_text, deckWords); 142 - if (aTextMatch && !bTextMatch) return 1; 143 - if (bTextMatch && !aTextMatch) return -1; 142 + if (aTextMatch && !bTextMatch) return -1; 143 + if (bTextMatch && !aTextMatch) return 1; 144 144 return 0; 145 145 }) 146 146 .slice(0, 3)
+5 -1
src/components/ListPreview.tsx
··· 34 34 } 35 35 36 36 function getCardIds(list: CollectionList): string[] { 37 - return list.items.filter(isCardItem).map((item) => item.scryfallId); 37 + // Reverse so newest cards appear first (on top of spread) 38 + return list.items 39 + .filter(isCardItem) 40 + .map((item) => item.scryfallId) 41 + .reverse(); 38 42 } 39 43 40 44 export function ListPreview({
+4
src/lib/deck-preview-utils.test.ts
··· 60 60 // Words that don't need singularization 61 61 ["merfolk", ["merfolk"]], 62 62 ["equipment", ["equipment"]], 63 + // Words ending in -ss (not plurals) 64 + ["prowess", ["prowess"]], 65 + ["boss", ["boss"]], 66 + ["moss", ["moss"]], 63 67 ])("%s -> %j", (input, expected) => { 64 68 expect(getSingularForms(input)).toEqual(expected); 65 69 });
+2 -1
src/lib/deck-preview-utils.ts
··· 42 42 word.endsWith("zzes")) 43 43 ) { 44 44 forms.push(word.slice(0, -2)); // boxes -> box, passes -> pass 45 - } else if (word.endsWith("s") && word.length > 1) { 45 + } else if (word.endsWith("s") && !word.endsWith("ss") && word.length > 1) { 46 + // Skip words ending in -ss (prowess, boss, moss) - not plurals 46 47 forms.push(word.slice(0, -1)); // bogles -> bogle, goblins -> goblin 47 48 } 48 49 return forms;