@@ -111,12 +111,10 @@ const processPastChallenge = (challenge) => {
111
111
class SubTrackChallengeView extends React . Component {
112
112
constructor ( props , context ) {
113
113
super ( props , context ) ;
114
- // this is current page number. starts with 0.
115
- // everytime we scroll at the bottom, we query from offset = pageNum * CHALLENGE_PER_PAGE
116
114
this . state = {
117
- // this is current page number. starts with 0 .
115
+ // this is current page number. starts with 1 .
118
116
// everytime we scroll at the bottom, we query from offset = pageNum * CHALLENGE_PER_PAGE
119
- pageNum : 0 ,
117
+ pageNum : 1 ,
120
118
// which challenge's modal should be poped. null means no modal
121
119
challengeIndexToPopModal : null ,
122
120
} ;
@@ -140,13 +138,17 @@ class SubTrackChallengeView extends React.Component {
140
138
userId,
141
139
} = this . props ;
142
140
141
+ const {
142
+ pageNum,
143
+ } = this . state ;
144
+
143
145
if ( track === 'DEVELOP' || track === 'DESIGN' ) {
144
146
if ( ! loadingSubTrackChallengesUUID ) {
145
147
loadSubtrackChallenges (
146
148
handle ,
147
149
auth . tokenV3 ,
148
150
track , subTrack ,
149
- 0 ,
151
+ pageNum ,
150
152
CHALLENGE_PER_PAGE ,
151
153
true ,
152
154
userId ,
@@ -155,11 +157,12 @@ class SubTrackChallengeView extends React.Component {
155
157
} else if ( track === 'DATA_SCIENCE' ) {
156
158
if ( subTrack === 'SRM' ) {
157
159
if ( ! loadingSRMUUID ) {
158
- loadSRM ( handle , auth . tokenV3 , 0 , CHALLENGE_PER_PAGE , true ) ;
160
+ // pageNum - 1 to match with v4 offset
161
+ loadSRM ( handle , auth . tokenV3 , pageNum - 1 , CHALLENGE_PER_PAGE , true ) ;
159
162
}
160
163
} else if ( subTrack === 'MARATHON_MATCH' ) {
161
164
if ( ! loadingMarathonUUID ) {
162
- loadMarathon ( handle , auth . tokenV3 , 0 , CHALLENGE_PER_PAGE , true ) ;
165
+ loadMarathon ( handle , userId , auth . tokenV3 , pageNum , CHALLENGE_PER_PAGE , true ) ;
163
166
}
164
167
}
165
168
}
@@ -204,12 +207,12 @@ class SubTrackChallengeView extends React.Component {
204
207
} else if ( track === 'DATA_SCIENCE' ) {
205
208
if ( subTrack === 'SRM' ) {
206
209
if ( ! loadingSRMUUID ) {
207
- loadSRM ( handle , auth . tokenV3 , pageNum + 1 , CHALLENGE_PER_PAGE , false ) ;
210
+ loadSRM ( handle , auth . tokenV3 , pageNum , CHALLENGE_PER_PAGE , false ) ;
208
211
this . setState ( { pageNum : pageNum + 1 } ) ;
209
212
}
210
213
} else if ( subTrack === 'MARATHON_MATCH' ) {
211
214
if ( ! loadingMarathonUUID ) {
212
- loadMarathon ( handle , auth . tokenV3 , pageNum + 1 , CHALLENGE_PER_PAGE , false ) ;
215
+ loadMarathon ( handle , userId , auth . tokenV3 , pageNum + 1 , CHALLENGE_PER_PAGE , false ) ;
213
216
this . setState ( { pageNum : pageNum + 1 } ) ;
214
217
}
215
218
}
@@ -245,7 +248,7 @@ class SubTrackChallengeView extends React.Component {
245
248
userId,
246
249
} = this . props ;
247
250
248
- if ( pageNum === 0
251
+ if ( pageNum === 1
249
252
&& ( loadingSubTrackChallengesUUID || loadingSRMUUID || loadingMarathonUUID ) ) {
250
253
return < LoadingIndicator /> ;
251
254
}
@@ -347,7 +350,6 @@ class SubTrackChallengeView extends React.Component {
347
350
userMarathons ,
348
351
item => ( {
349
352
...item ,
350
- submissionEndDate : _ . get ( item , 'rounds.0.systemTestEndAt' ) ,
351
353
pointTotal : _ . get ( item , 'rounds.0.userMMDetails.pointTotal' ) ,
352
354
} ) ,
353
355
) ;
@@ -440,10 +442,18 @@ function mapDispatchToProps(dispatch) {
440
442
dispatch ( action . getUserSrmInit ( handle , uuid ) ) ;
441
443
dispatch ( action . getUserSrmDone ( uuid , handle , tokenV3 , pageNum , pageSize , refresh ) ) ;
442
444
} ,
443
- loadMarathon : ( handle , tokenV3 , pageNum , pageSize , refresh ) => {
445
+ loadMarathon : ( handle , memberId , tokenV3 , pageNum , pageSize , refresh ) => {
444
446
const uuid = shortId ( ) ;
445
447
dispatch ( action . getUserMarathonInit ( handle , uuid ) ) ;
446
- dispatch ( action . getUserMarathonDone ( uuid , handle , tokenV3 , pageNum , pageSize , refresh ) ) ;
448
+ dispatch ( action . getUserMarathonDone (
449
+ uuid ,
450
+ handle ,
451
+ memberId ,
452
+ tokenV3 ,
453
+ pageNum ,
454
+ pageSize ,
455
+ refresh ,
456
+ ) ) ;
447
457
} ,
448
458
} ;
449
459
}
0 commit comments