fix: no existing cache overwrites for neighbors

This commit is contained in:
TrèsAbhi committed 2023-11-14 10:29:57 -06:00
1 parent e79c4a1e3f
commit ca8dd5a702
1 file changed
+6 -2
+6 -2
View File
@@ -282,10 +282,14 @@ export default function Page() {
usePlayersCache.setState( usePlayersCache.setState(
produce((draft: PlayersCache) => { produce((draft: PlayersCache) => {
neighbors.forEach((neighbor) => { neighbors.forEach((neighbor) => {
draft[region][season][neighbor.number - 1] = { const position = neighbor.number - 1;
if (!(position in draft[region][season])) {
draft[region][season][position] = {
id: neighbor.spa_id, id: neighbor.spa_id,
score: neighbor.score, score: neighbor.score,
} satisfies BlitzkriegRatingsLeaderboardEntry; } satisfies BlitzkriegRatingsLeaderboardEntry;
}
}); });
}), }),
); );
@@ -642,7 +646,7 @@ export default function Page() {
}); });
cacheNeighbors( cacheNeighbors(
players[region][season][position].id, players[region][season][position].id,
ROWS_PER_PAGE * 3, 4 * ROWS_PER_PAGE - 2,
); );
} }
} else { } else {