Skip to content

Commit bffd66c

Browse files
committed
Adds delay to challenge refresh on register/unregister to allow time for API to update.
1 parent 7581820 commit bffd66c

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/actions/challenge.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
import _ from 'lodash';
7+
import { config } from 'topcoder-react-utils';
78
import { createActions } from 'redux-actions';
89
import { getService as getChallengesService } from '../services/challenges';
910
import { getApiV2 } from '../services/api';
@@ -106,7 +107,13 @@ function registerDone(auth, challengeId) {
106107
.register(challengeId)
107108
/* As a part of registration flow we silently update challenge details,
108109
* reusing for this purpose the corresponding action handler. */
109-
.then(() => getDetailsDone(challengeId, auth.tokenV3, auth.tokenV2));
110+
// Uses a delay to allow API time to update
111+
.then(() => new Promise(
112+
resolve => setTimeout(
113+
() => resolve(getDetailsDone(challengeId, auth.tokenV3, auth.tokenV2)),
114+
config.CHALLENGE_DETAILS_REFRESH_DELAY,
115+
),
116+
));
110117
}
111118

112119
/**
@@ -131,7 +138,13 @@ function unregisterDone(auth, challengeId) {
131138
.unregister(challengeId)
132139
/* As a part of unregistration flow we silently update challenge details,
133140
* reusing for this purpose the corresponding action handler. */
134-
.then(() => getDetailsDone(challengeId, auth.tokenV3, auth.tokenV2));
141+
// Uses a delay to allow API time to update
142+
.then(() => new Promise(
143+
resolve => setTimeout(
144+
() => resolve(getDetailsDone(challengeId, auth.tokenV3, auth.tokenV2)),
145+
config.CHALLENGE_DETAILS_REFRESH_DELAY,
146+
),
147+
));
135148
}
136149

137150
/**

0 commit comments

Comments
 (0)