diff --git a/client/src/components/layouts/components/guide/SideNav.js b/client/src/components/layouts/components/guide/SideNav.js index 87916b5dd2..e194a7d667 100644 --- a/client/src/components/layouts/components/guide/SideNav.js +++ b/client/src/components/layouts/components/guide/SideNav.js @@ -27,30 +27,6 @@ class SideNav extends Component { this.renderParent = this.renderParent.bind(this); } - componentDidMount() { - if (typeof window !== 'undefined') { - const pathMap = window.location.pathname - .slice(1) - .split('/') - .slice(0, -1) - .reduce((map, current, i, pathArray) => { - const path = - i !== 0 ? map[pathArray[i - 1]] + `/${current}` : `/${current}`; - return { - ...map, - [current]: path - }; - }, {}); - - return Object.keys(pathMap) - .map(key => pathMap[key]) - .forEach(path => { - this.props.toggleExpandedState(path); - }); - } - return null; - } - renderPanels(parents, pages) { if (!parents) { return 'No Parents Here'; diff --git a/client/src/components/layouts/components/guide/redux/side-navigation-saga.js b/client/src/components/layouts/components/guide/redux/side-navigation-saga.js index bb666400df..eec049dccf 100644 --- a/client/src/components/layouts/components/guide/redux/side-navigation-saga.js +++ b/client/src/components/layouts/components/guide/redux/side-navigation-saga.js @@ -1,14 +1,31 @@ -import { takeEvery, put } from 'redux-saga/effects'; +import { takeEvery, put, all } from 'redux-saga/effects'; -// import { put, takeEvery, take } from 'redux-saga/effects'; - -import { openDonationModal } from '../../../../../redux'; +import { toggleExpandedState } from './'; +import { types as appTypes } from '../../../../../redux'; function* showDonateModalSaga() { - console.log('hello'); - yield put(openDonationModal()); + let guideRegex = /^\/guide\//; + let onGuide = guideRegex.test(window.location.pathname); + if (onGuide && typeof window !== 'undefined') { + const pathMap = window.location.pathname + .slice(1) + .split('/') + .slice(0, -1) + .reduce((map, current, i, pathArray) => { + const path = + i !== 0 ? map[pathArray[i - 1]] + `/${current}` : `/${current}`; + return { + ...map, + [current]: path + }; + }, {}); + + let routes = Object.keys(pathMap).map(key => pathMap[key]); + + yield all(routes.map(route => put(toggleExpandedState(route)))); + } } -export function createSideNavigationSaga(types) { - takeEvery(types.toggleDisplaySideNav, showDonateModalSaga); +export function createSideNavigationSaga() { + return [takeEvery(appTypes.appMount, showDonateModalSaga)]; }