fix(shop): make favorites sort prioritize wishlist count first

This commit is contained in:
End Nightshade 2026-02-16 21:57:06 -07:00
parent fcc862e9ff
commit aea9bd81de
No known key found for this signature in database

View file

@ -59,7 +59,15 @@
let sortedItems = $derived.by(() => {
let items = [...filteredItems];
if (sortBy === 'favorites') {
return items.sort((a, b) => b.heartCount - a.heartCount);
return items.sort((a, b) => {
if (b.heartCount !== a.heartCount) {
return b.heartCount - a.heartCount;
}
if (a.userHearted !== b.userHearted) {
return a.userHearted ? -1 : 1;
}
return a.id - b.id;
});
} else if (sortBy === 'probability') {
return items.sort((a, b) => b.effectiveProbability - a.effectiveProbability);
} else if (sortBy === 'cost') {
@ -224,7 +232,7 @@
? 'bg-black text-white'
: 'hover:border-dashed'}"
>
{$t.shop.favorites}
{$t.shop.favorites} (most wished, then yours)
</button>
<button
onclick={() => (sortBy = 'probability')}