changed fetchMapUi epic to add extra param - initialNode added util method to open path in the map by node name changed action handler for fetchMapUi.complete to open initialNode changed map component to set scroll on component mount and update added attribute to challenge component to find challenge node by name extracted createEventMetaCreator into separate file to break circular dependencies Closes #16248
44 lines
1.0 KiB
JavaScript
44 lines
1.0 KiB
JavaScript
import { ofType } from 'redux-epic';
|
|
import debug from 'debug';
|
|
|
|
import {
|
|
types as appTypes,
|
|
createErrorObservable,
|
|
currentChallengeSelector
|
|
} from '../../redux';
|
|
import { types, fetchMapUiComplete } from './';
|
|
import { langSelector } from '../../Router/redux';
|
|
import { shapeChallenges } from '../../redux/utils';
|
|
|
|
const isDev = debug.enabled('fcc:*');
|
|
|
|
export default function fetchMapUiEpic(
|
|
actions,
|
|
{ getState },
|
|
{ services }
|
|
) {
|
|
return actions::ofType(
|
|
appTypes.appMounted,
|
|
types.fetchMapUi.start
|
|
)
|
|
.flatMapLatest(() => {
|
|
const lang = langSelector(getState());
|
|
const options = {
|
|
params: { lang },
|
|
service: 'map-ui'
|
|
};
|
|
return services.readService$(options)
|
|
.retry(3)
|
|
.map(({ entities, ...res }) => ({
|
|
entities: shapeChallenges(
|
|
entities,
|
|
isDev
|
|
),
|
|
initialNode: currentChallengeSelector(getState()),
|
|
...res
|
|
}))
|
|
.map(fetchMapUiComplete)
|
|
.catch(createErrorObservable);
|
|
});
|
|
}
|