Skip to content

Commit ce87a58

Browse files
committed
issue #97
1 parent f890395 commit ce87a58

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

src/containers/Submission/Submit/Uploading/index.jsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React from "react";
1+
import React, { useEffect, useRef } from "react";
22
import PT from "prop-types";
3-
import { Link } from "@reach/router";
3+
import { Link, navigate } from "@reach/router";
44
import { PrimaryButton, DefaultButton as Button } from "components/Buttons";
55
import { COMPETITION_TRACKS, CHALLENGES_URL } from "../../../../constants";
66
import RobotHappy from "assets/icons/robot-happy.svg";
@@ -20,6 +20,20 @@ const Uploading = ({
2020
uploadProgress,
2121
back,
2222
}) => {
23+
const propsRef = useRef();
24+
propsRef.current = { submitDone, challengeId };
25+
26+
useEffect(() => {
27+
return () => {
28+
if (propsRef.current.submitDone) {
29+
const backUrl = window.location.pathname;
30+
if (backUrl === `${CHALLENGES_URL}/${challengeId}`) {
31+
navigate(`${CHALLENGES_URL}/${propsRef.current.challengeId}?reload=true`);
32+
}
33+
}
34+
}
35+
}, []);
36+
2337
return (
2438
<div styleName="container">
2539
<div styleName="uploading">

src/containers/challenge-detail/index.jsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ class ChallengeDetailPageContainer extends React.Component {
221221
challenge,
222222
// loadingRecommendedChallengesUUID,
223223
history,
224+
loadChallengeDetails,
225+
loadFullChallengeDetails,
226+
isLoadingChallenge,
227+
isLoadingTerms,
224228
} = this.props;
225229

226230
if (
@@ -247,6 +251,15 @@ class ChallengeDetailPageContainer extends React.Component {
247251
// getAllRecommendedChallenges(auth.tokenV3, recommendedTechnology);
248252
// }
249253

254+
const query = new URLSearchParams(history.location.search);
255+
const isReloading = isLoadingChallenge || isLoadingTerms;
256+
if (query.get('reload') && !isReloading) {
257+
history.replace(history.location.pathname, history.state);
258+
loadChallengeDetails(nextProps.auth, challengeId, loadFullChallengeDetails);
259+
260+
return;
261+
}
262+
250263
const { thriveArticles } = this.state;
251264
const userId = _.get(this, "props.auth.user.userId");
252265
const nextUserId = _.get(nextProps, "auth.user.userId");

0 commit comments

Comments
 (0)