From 191906192b52d4fea435c0292085732c41378f80 Mon Sep 17 00:00:00 2001 From: kyuuseiryuu Date: Wed, 25 Mar 2026 11:19:59 +0900 Subject: [PATCH] feat(cache): remove redis caching and add force refresh mechanism - Remove Redis-based caching logic from uidScoreStore and xcxApi. - Add force refresh support to uidScoreRequest in GroupingPrediction component. - Update server API /api/user/nowScores to accept force parameter. - Always show refresh button in GroupingPrediction regardless of data state. - Change default sort type in FavPlayersPage to SCORE_DOWN. - Clean up unused imports from server.ts. This change ensures user scores are always up-to-date by bypassing cache when needed, preventing issues with stale data during manual sync operations. --- src/components/GroupingPrediction.tsx | 8 ++++---- src/index.tsx | 5 +++-- src/page/FavPlayersPage.tsx | 4 ++-- src/services/uidScoreStore.ts | 16 +++------------- src/services/xcxApi.ts | 6 +++--- src/utils/server.ts | 4 +--- 6 files changed, 16 insertions(+), 27 deletions(-) diff --git a/src/components/GroupingPrediction.tsx b/src/components/GroupingPrediction.tsx index 214f3e0..4696105 100644 --- a/src/components/GroupingPrediction.tsx +++ b/src/components/GroupingPrediction.tsx @@ -30,9 +30,9 @@ enum OrderScore { export const GroupingPrediction: React.FC = props => { const { uidScore } = useLoaderData<{ uidScore: Map}>(); - const uidScoreRequest = useRequest(async () => { + const uidScoreRequest = useRequest(async (force?: boolean) => { const uids = props.players?.map(player => player.uid).filter(Boolean); - const data = await fetch(`/api/user/nowScores`, { + const data = await fetch(`/api/user/nowScores?force=${force ? 'true' : 'false'}`, { method: "POST", body: JSON.stringify({ uids }), }).then(res => res.json()).catch(() => ({})); @@ -86,7 +86,7 @@ export const GroupingPrediction: React.FC = props => { }); }, [players, grouped, groupLen, maxPlayerSize]); const handleSyncUidScore = useCallback(() => { - uidScoreRequest.runAsync(); + uidScoreRequest.runAsync(true); }, []); return ( <> @@ -115,7 +115,7 @@ export const GroupingPrediction: React.FC = props => { OrderScore.年度积分, ]} /> -