Skip to content

Commit b50589c

Browse files
author
任庆伟
committed
Fix failed test scenario
1 parent 336aa77 commit b50589c

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

src/shared/components/challenge-listing/index.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@ import Listing from './Listing';
1616
import ChallengeCardPlaceholder from './placeholders/ChallengeCard';
1717
import SRMCard from './SRMCard';
1818

19-
import { updateQuery } from 'utils/url';
2019
import './style.scss';
2120

2221
// Number of challenge placeholder card to display
2322
const CHALLENGE_PLACEHOLDER_COUNT = 8;
2423

2524
export default function ChallengeListing(props) {
26-
updateQuery({ });
2725
let challenges = props.challenges;
2826

2927
if (props.communityFilter) {

src/shared/reducers/challenge-listing/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,12 @@ export function factory(req) {
271271

272272
if (req) {
273273
state.filter = req.query.filter;
274-
if (!!state.filter.startDate && moment(state.filter.startDate).isValid() === false) {
274+
if (!!state.filter && !!state.filter.startDate
275+
&& moment(state.filter.startDate).isValid() === false) {
275276
delete state.filter.startDate;
276277
}
277-
if (!!state.filter.endDate && moment(state.filter.endDate).isValid() === false) {
278+
if (!!state.filter && !!state.filter.endDate
279+
&& moment(state.filter.endDate).isValid() === false) {
278280
delete state.filter.endDate;
279281
}
280282
state.selectedCommunityId = req.query.communityId;

src/shared/routes/Topcoder/ChallengeListing.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import LoadingIndicator from 'components/LoadingIndicator';
88
import qs from 'qs';
99
import React from 'react';
1010
import { SplitRoute } from 'utils/router';
11+
import { updateQuery } from 'utils/url';
1112

1213
export default function ChallengeListingRoute() {
1314
return (
@@ -19,6 +20,7 @@ export default function ChallengeListingRoute() {
1920
/* webpackChunkName: "challenge-listing" */
2021
'containers/challenge-listing/Listing',
2122
).then(({ default: ChallengeListing }) => {
23+
updateQuery({ });
2224
const query = renderProps.location.search ?
2325
qs.parse(renderProps.location.search.slice(1)) : null;
2426
const currencyFromUrl = _.get(query, 'currency');

src/shared/utils/url.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ export function updateQuery(update) {
2929
if (_.isUndefined(value)) delete query[key];
3030
else query[key] = value;
3131
});
32-
if (!!query.filter.startDate && moment(query.filter.startDate).isValid() === false) {
32+
if (!!query.filter && !!query.filter.startDate
33+
&& moment(query.filter.startDate).isValid() === false) {
3334
delete query.filter.startDate;
34-
} else if (query.filter.endDate && moment(query.filter.endDate).isValid() === false) {
35+
} else if (!!query.filter && !!query.filter.endDate
36+
&& moment(query.filter.endDate).isValid() === false) {
3537
delete query.filter.endDate;
3638
}
3739

0 commit comments

Comments
 (0)