File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import "./styles.scss";
14
14
15
15
const Challenges = ( {
16
16
challenges,
17
+ challengesMeta,
17
18
search,
18
19
page,
19
20
perPage,
@@ -38,6 +39,16 @@ const Challenges = ({
38
39
checkIsLoggedIn ( ) ;
39
40
} , [ ] ) ;
40
41
42
+ // reset pagination
43
+ if ( page > 1 && challengesMeta . total && challengesMeta . total > 0 && challenges . length === 0 ) {
44
+ updateFilter ( {
45
+ page : 1
46
+ } )
47
+ updateQuery ( {
48
+ page : 1
49
+ } )
50
+ }
51
+
41
52
const BUCKET_OPEN_FOR_REGISTRATION = constants . FILTER_BUCKETS [ 1 ] ;
42
53
const isRecommended = recommended && bucket === BUCKET_OPEN_FOR_REGISTRATION ;
43
54
const sortByValue = isRecommended
@@ -124,6 +135,7 @@ const mapStateToProps = (state) => ({
124
135
endDateStart : state . filter . challenge . endDateStart ,
125
136
startDateEnd : state . filter . challenge . startDateEnd ,
126
137
challenges : state . challenges . challenges ,
138
+ challengesMeta : state . challenges . challengesMeta ,
127
139
bucket : state . filter . challenge . bucket ,
128
140
recommended : state . filter . challenge . recommended ,
129
141
recommendedChallenges : state . challenges . recommendedChallenges ,
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ const defaultState = {
4
4
loadingChallenges : false ,
5
5
loadingChallengesError : null ,
6
6
challenges : [ ] ,
7
+ challengesMeta : { } ,
7
8
total : 0 ,
8
9
loadingRecommendedChallenges : false ,
9
10
loadingRecommendedChallengesError : null ,
@@ -31,6 +32,7 @@ function onGetChallengesDone(state, { payload }) {
31
32
loadingChallenges : false ,
32
33
loadingChallengesError : null ,
33
34
challenges : payload . challenges ,
35
+ challengesMeta : payload . challenges ?. meta ,
34
36
total : payload . total ,
35
37
openForRegistrationCount : payload . openForRegistrationCount ,
36
38
initialized : true ,
You can’t perform that action at this time.
0 commit comments