Skip to content

Commit 6fbfa47

Browse files
committed
Fix #1101 and a few refactoring.
1 parent f751354 commit 6fbfa47

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

atcoder-problems-frontend/src/api/APIClient.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,15 @@ export const useVirtualContestSubmissions = (
323323
return submissionChunks.flatMap((x) => x);
324324
};
325325

326+
const custom_key =
327+
"useVirtualContestSubmissions&" +
328+
(users.length === 0
329+
? "empty"
330+
: users.length === 1
331+
? users[0]
332+
: "multiuser");
326333
return useSWRData(
327-
"useVirtualContestSubmissions",
334+
custom_key,
328335
() => (users.length > 0 ? fetcher() : Promise.resolve([])),
329336
{
330337
refreshInterval,

atcoder-problems-frontend/src/pages/Internal/VirtualContest/ShowContest/ContestTable.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ export const ContestTable = (props: Props) => {
154154
end,
155155
props.enableAutoRefresh
156156
);
157-
if (!submissions.data && !submissions.error) {
158-
return <Spinner />;
157+
if (submissions.error) {
158+
return <Alert color="danger">Failed to fetch submissions.</Alert>;
159159
}
160160
if (!submissions.data) {
161-
return <Alert color="danger">Failed to fetch submissions.</Alert>;
161+
return <Spinner />;
162162
}
163163

164164
const modelArray = consolidateModels(problems, problemMap, problemModels);

atcoder-problems-frontend/src/pages/Internal/VirtualContest/ShowContest/index.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,22 @@ const Problems = (props: {
6868
}) => {
6969
const { alreadyJoined } = props;
7070
const submissions = useVirtualContestSubmissions(
71-
[props.atCoderUserId],
71+
alreadyJoined ? [props.atCoderUserId] : [],
7272
props.problems.map((p) => p.item.id),
7373
props.start,
7474
props.end,
7575
false
7676
);
7777
const pointOverrideMap = constructPointOverrideMap(props.problems);
78-
const showUserResults =
79-
props.atCoderUserId !== "" &&
80-
submissions.data !== null &&
81-
submissions.data !== undefined;
78+
const showUserResults = alreadyJoined && submissions.data;
8279
const results = submissions.data
8380
? reduceUserContestResult(submissions.data, (id) =>
8481
pointOverrideMap.get(id)
8582
)
8683
: new Map<UserId, ReducedProblemResult>();
8784
const ResultIcon = (props: { id: ProblemId }) => {
8885
const result = results.get(props.id);
89-
if (!alreadyJoined || !result) return null;
86+
if (!result) return null;
9087
if (result.accepted) {
9188
return <FcCheckmark />;
9289
} else {
@@ -210,7 +207,7 @@ const Standings = (props: StandingsProps) => {
210207
checked={showRating}
211208
onChange={(): void => setShowRating(!showRating)}
212209
/>
213-
{alreadyJoined && (
210+
{alreadyJoined && contestInfo.mode === null && (
214211
<CustomInput
215212
type="switch"
216213
id="pinMe"

0 commit comments

Comments
 (0)