Fix rendering specific hike from server
This commit is contained in:
@ -31,7 +31,7 @@ const fetchOptions = {
|
||||
fetchAction: 'fetchHikes',
|
||||
|
||||
isPrimed: ({ hikes }) => hikes && !!hikes.length,
|
||||
getPayload: ({ params: { dashedName } }) => dashedName,
|
||||
getActionArgs: ({ params: { dashedName } }) => [ dashedName ],
|
||||
shouldContainerFetch(props, nextProps) {
|
||||
return props.params.dashedName !== nextProps.params.dashedName;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import types from './types';
|
||||
import { fetchHikesCompleted } from './actions';
|
||||
import { handleError } from '../../../redux/types';
|
||||
|
||||
import { getCurrentHike } from './utils';
|
||||
import { findCurrentHike } from './utils';
|
||||
|
||||
// const log = debug('fcc:fetch-hikes-saga');
|
||||
const hike = new Schema('hike', { idAttribute: 'dashedName' });
|
||||
@ -30,7 +30,7 @@ export default ({ services }) => ({ dispatch }) => next => {
|
||||
results: result.hikes
|
||||
};
|
||||
|
||||
const currentHike = getCurrentHike(hikes, dashedName);
|
||||
const currentHike = findCurrentHike(hikes, dashedName);
|
||||
|
||||
return fetchHikesCompleted(hikes, currentHike);
|
||||
})
|
||||
|
@ -18,7 +18,7 @@ function getFirstHike(hikes) {
|
||||
// hikes: Hikes,
|
||||
// dashedName: String
|
||||
// }) => String
|
||||
export function findCurrentHike(hikes = {}, dashedName) {
|
||||
export function findCurrentHike(hikes, dashedName) {
|
||||
if (!dashedName) {
|
||||
return getFirstHike(hikes) || {};
|
||||
}
|
||||
@ -32,7 +32,7 @@ export function findCurrentHike(hikes = {}, dashedName) {
|
||||
})
|
||||
.reduce((throwAway, hike) => {
|
||||
return hike;
|
||||
}, {});
|
||||
}, '');
|
||||
}
|
||||
|
||||
export function getCurrentHike(hikes = {}, dashedName) {
|
||||
|
Reference in New Issue
Block a user