Add ettempts in contests
This commit is contained in:
@@ -9,6 +9,7 @@ import { fetchMissionById, setMissionsStatus } from '../redux/slices/missions';
|
||||
import Header from '../views/mission/statement/Header';
|
||||
import MissionSubmissions from '../views/mission/statement/MissionSubmissions';
|
||||
import { useQuery } from '../hooks/useQuery';
|
||||
import { fetchMyAttemptsInContest } from '../redux/slices/contests';
|
||||
|
||||
const Mission = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
@@ -20,6 +21,10 @@ const Mission = () => {
|
||||
const missionStatus = useAppSelector(
|
||||
(state) => state.missions.statuses.fetchById,
|
||||
);
|
||||
const attempt = useAppSelector(
|
||||
(state) => state.contests.fetchMyAttemptsInContest.attempts[0],
|
||||
);
|
||||
|
||||
const missionIdNumber = Number(missionId);
|
||||
|
||||
const query = useQuery();
|
||||
@@ -44,6 +49,9 @@ const Mission = () => {
|
||||
if (pollingRef.current) return;
|
||||
|
||||
pollingRef.current = setInterval(async () => {
|
||||
if (contestId) {
|
||||
dispatch(fetchMyAttemptsInContest(contestId));
|
||||
}
|
||||
dispatch(fetchMySubmitsByMission(missionIdNumber));
|
||||
|
||||
const hasWaiting = submissionsRef.current.some(
|
||||
@@ -63,6 +71,12 @@ const Mission = () => {
|
||||
}, 5000); // 10 секунд
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (contestId) {
|
||||
dispatch(fetchMyAttemptsInContest(contestId));
|
||||
}
|
||||
}, [contestId]);
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetchMissionById(missionIdNumber));
|
||||
dispatch(fetchMySubmitsByMission(missionIdNumber));
|
||||
@@ -194,7 +208,8 @@ const Mission = () => {
|
||||
language: language,
|
||||
languageVersion: 'latest',
|
||||
sourceCode: code,
|
||||
contestId: contestId,
|
||||
contestAttemptId:
|
||||
attempt?.attemptId,
|
||||
}),
|
||||
).unwrap();
|
||||
dispatch(
|
||||
|
||||
Reference in New Issue
Block a user