Skip to content

A submission being sent too soon is not handled properly when throttling. #1653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ const ContestSolutionSubmitPage = () => {
data,
isLoading,
isError,
isFetching,
error,
refetch,
} = useGetContestUserParticipationQuery({ id: Number(contestId!), isOfficial: isCompete });
Expand Down Expand Up @@ -286,7 +287,9 @@ const ContestSolutionSubmitPage = () => {
const shouldSubmitBeDisabled = isCodeStrategyAndCodeIsEmptyOrTooShort ||
isFileUploadAndFileIsEmpty ||
!selectedSubmissionType ||
secondsUntilTimerEnds > 0;
secondsUntilTimerEnds > 0 ||
isLoading ||
isFetching;

setRemainingTime(secondsUntilTimerEnds);
setIsSubmitButtonDisabled(shouldSubmitBeDisabled);
Expand All @@ -302,7 +305,7 @@ const ContestSolutionSubmitPage = () => {
return () => {
clearInterval(intervalId);
};
}, [ lastSubmissionTime, selectedSubmissionType, submissionCode, uploadedFile, userSubmissionsTimeLimit ]);
}, [ isFetching, isLoading, lastSubmissionTime, selectedSubmissionType, submissionCode, uploadedFile, userSubmissionsTimeLimit ]);

// Manage remaining time for compete contest
useEffect(() => {
Expand Down Expand Up @@ -354,7 +357,9 @@ const ContestSolutionSubmitPage = () => {
}, [ isLoading, isError, isRegisteredParticipant, isActiveParticipant, contestId, isCompete, navigate, slug, isInvalidated ]);

useEffect(() => {
setSubmissionCode('');
// Only clear code if it's a new problem
// Don’t reset if there’s already code (protect against unintended clears)
setSubmissionCode((prev) => prev ?? '');
}, [ selectedContestDetailsProblem ]);

// Ensure contest details are set in state
Expand Down