Commit 6ff038f3 authored by Florent Chehab's avatar Florent Chehab

Fixed data invalidation on unmount

parent 8583ed58
...@@ -50,10 +50,7 @@ export function {{obj.name}}IsLoading(bool) { ...@@ -50,10 +50,7 @@ export function {{obj.name}}IsLoading(bool) {
}; };
} }
export function {{obj.name}}Invalidated(bool, resetObj=false) { export function {{obj.name}}Invalidated(bool) {
if (resetObj){
{{obj.name}}FetchDataSuccess({}, false);
}
return { return {
type: {{obj.NAME}}_INVALIDATED, type: {{obj.NAME}}_INVALIDATED,
invalidated: bool invalidated: bool
...@@ -96,11 +93,7 @@ export function {{obj.name}}ElFetchHasError(bool, error) { ...@@ -96,11 +93,7 @@ export function {{obj.name}}ElFetchHasError(bool, error) {
}; };
} }
export function {{obj.name}}ElInvalidated(bool, resetObj=false) { export function {{obj.name}}ElInvalidated(bool) {
if (resetObj){
{{obj.name}}ElFetchDataSuccess({}, false);
}
return { return {
type: {{obj.NAME}}_EL_INVALIDATED, type: {{obj.NAME}}_EL_INVALIDATED,
invalidated: bool invalidated: bool
......
...@@ -7,7 +7,7 @@ import __pick from 'lodash/pick'; ...@@ -7,7 +7,7 @@ import __pick from 'lodash/pick';
import Markdown from '../../shared/Markdown'; import Markdown from '../../shared/Markdown';
import Module from '../shared/Module'; import Module, { getInvalidateDataFunction } from '../shared/Module';
import GenericModule from '../shared/GenericModule'; import GenericModule from '../shared/GenericModule';
import GenericGroupModule from '../shared/GenericGroupModule'; import GenericGroupModule from '../shared/GenericGroupModule';
...@@ -17,6 +17,7 @@ import CountryDriEditor from '../editors/CountryDriEditor'; ...@@ -17,6 +17,7 @@ import CountryDriEditor from '../editors/CountryDriEditor';
import { import {
countryDriFetchData, countryDriFetchData,
countryDriInvalidated, countryDriInvalidated,
countryDriFetchDataSuccess,
} from '../../../generated/actions'; } from '../../../generated/actions';
const styles = theme => ({ const styles = theme => ({
...@@ -110,7 +111,7 @@ const mapDispatchToProps = (dispatch) => { ...@@ -110,7 +111,7 @@ const mapDispatchToProps = (dispatch) => {
fetchData: { fetchData: {
countryDri: (countryId) => dispatch(countryDriFetchData(countryId)), countryDri: (countryId) => dispatch(countryDriFetchData(countryId)),
}, },
invalidateData: (resetObj = false) => dispatch(countryDriInvalidated(true, resetObj)) invalidateData: getInvalidateDataFunction(dispatch, countryDriInvalidated, countryDriFetchDataSuccess)
}; };
}; };
......
...@@ -5,7 +5,7 @@ import compose from 'recompose/compose'; ...@@ -5,7 +5,7 @@ import compose from 'recompose/compose';
import { connect } from "react-redux"; import { connect } from "react-redux";
import __pick from 'lodash/pick'; import __pick from 'lodash/pick';
import Module from '../shared/Module'; import Module, { getInvalidateDataFunction } from '../shared/Module';
import GenericModule from '../shared/GenericModule'; import GenericModule from '../shared/GenericModule';
import GenericGroupModule from '../shared/GenericGroupModule'; import GenericGroupModule from '../shared/GenericGroupModule';
...@@ -15,6 +15,7 @@ import CountryScholarshipsEditor from '../editors/CountryScholarshipsEditor'; ...@@ -15,6 +15,7 @@ import CountryScholarshipsEditor from '../editors/CountryScholarshipsEditor';
import { import {
countryScholarshipsFetchData, countryScholarshipsFetchData,
countryScholarshipsFetchDataSuccess,
countryScholarshipsInvalidated, countryScholarshipsInvalidated,
} from '../../../generated/actions'; } from '../../../generated/actions';
...@@ -131,7 +132,7 @@ const mapDispatchToProps = (dispatch) => { ...@@ -131,7 +132,7 @@ const mapDispatchToProps = (dispatch) => {
fetchData: { fetchData: {
countryScholarships: (countryId) => dispatch(countryScholarshipsFetchData(countryId)), countryScholarships: (countryId) => dispatch(countryScholarshipsFetchData(countryId)),
}, },
invalidateData: (resetObj = false) => dispatch(countryScholarshipsInvalidated(true, resetObj)) invalidateData: getInvalidateDataFunction(dispatch, countryScholarshipsInvalidated, countryScholarshipsFetchDataSuccess)
}; };
}; };
......
...@@ -7,7 +7,7 @@ import __pick from 'lodash/pick'; ...@@ -7,7 +7,7 @@ import __pick from 'lodash/pick';
import Markdown from '../../shared/Markdown'; import Markdown from '../../shared/Markdown';
import Module from '../shared/Module'; import Module, { getInvalidateDataFunction } from '../shared/Module';
import GenericModule from '../shared/GenericModule'; import GenericModule from '../shared/GenericModule';
import GenericGroupModule from '../shared/GenericGroupModule'; import GenericGroupModule from '../shared/GenericGroupModule';
...@@ -17,6 +17,7 @@ import UniversityDriEditor from '../editors/UniversityDriEditor'; ...@@ -17,6 +17,7 @@ import UniversityDriEditor from '../editors/UniversityDriEditor';
import { import {
universityDriFetchData, universityDriFetchData,
universityDriInvalidated, universityDriInvalidated,
universityDriFetchDataSuccess,
} from '../../../generated/actions'; } from '../../../generated/actions';
const styles = theme => ({ const styles = theme => ({
...@@ -113,7 +114,7 @@ const mapDispatchToProps = (dispatch) => { ...@@ -113,7 +114,7 @@ const mapDispatchToProps = (dispatch) => {
fetchData: { fetchData: {
universityDri: (univId) => dispatch(universityDriFetchData(univId)), universityDri: (univId) => dispatch(universityDriFetchData(univId)),
}, },
invalidateData: (resetObj = false) => dispatch(universityDriInvalidated(true, resetObj)) invalidateData: getInvalidateDataFunction(dispatch, universityDriInvalidated, universityDriFetchDataSuccess)
}; };
}; };
......
...@@ -8,19 +8,20 @@ import __pick from 'lodash/pick'; ...@@ -8,19 +8,20 @@ import __pick from 'lodash/pick';
import Markdown from '../../shared/Markdown'; import Markdown from '../../shared/Markdown';
import Typography from '@material-ui/core/Typography'; import Typography from '@material-ui/core/Typography';
import Module from '../shared/Module'; import GenericModule from '../shared/GenericModule';
import TextLink from '../../other/TextLink'; import TextLink from '../../other/TextLink';
import Grid from '@material-ui/core/Grid'; import Grid from '@material-ui/core/Grid';
import Divider from '@material-ui/core/Divider'; import Divider from '@material-ui/core/Divider';
import PhotoSizeSelectActualIcon from '@material-ui/icons/PhotoSizeSelectActual'; import PhotoSizeSelectActualIcon from '@material-ui/icons/PhotoSizeSelectActual';
import GenericModule from '../shared/GenericModule'; import Module, { getInvalidateDataFunction } from '../shared/Module';
import UniversityGeneralEditor from '../editors/UniversityGeneralEditor'; import UniversityGeneralEditor from '../editors/UniversityGeneralEditor';
import { import {
universitiesElFetchData, universitiesElFetchData,
universitiesElInvalidated, universitiesElInvalidated,
universitiesElFetchDataSuccess,
} from '../../../generated/actions'; } from '../../../generated/actions';
const styles = theme => ({ const styles = theme => ({
...@@ -128,7 +129,7 @@ const mapDispatchToProps = (dispatch) => { ...@@ -128,7 +129,7 @@ const mapDispatchToProps = (dispatch) => {
fetchData: { fetchData: {
universitiesEl: (univId) => dispatch(universitiesElFetchData(univId)), universitiesEl: (univId) => dispatch(universitiesElFetchData(univId)),
}, },
invalidateData: () => dispatch(universitiesElInvalidated(true, true)) invalidateData: getInvalidateDataFunction(dispatch, universitiesElInvalidated, universitiesElFetchDataSuccess)
}; };
}; };
......
...@@ -5,7 +5,7 @@ import compose from 'recompose/compose'; ...@@ -5,7 +5,7 @@ import compose from 'recompose/compose';
import { connect } from "react-redux"; import { connect } from "react-redux";
import __pick from 'lodash/pick'; import __pick from 'lodash/pick';
import Module from '../shared/Module'; import Module, { getInvalidateDataFunction } from '../shared/Module';
import GenericModule from '../shared/GenericModule'; import GenericModule from '../shared/GenericModule';
import GenericGroupModule from '../shared/GenericGroupModule'; import GenericGroupModule from '../shared/GenericGroupModule';
...@@ -16,6 +16,7 @@ import UniversityScholarshipsEditor from '../editors/UniversityScholarshipsEdito ...@@ -16,6 +16,7 @@ import UniversityScholarshipsEditor from '../editors/UniversityScholarshipsEdito
import { import {
universityScholarshipsFetchData, universityScholarshipsFetchData,
universityScholarshipsInvalidated, universityScholarshipsInvalidated,
universityScholarshipsFetchDataSuccess,
} from '../../../generated/actions'; } from '../../../generated/actions';
const styles = theme => ({ const styles = theme => ({
...@@ -130,7 +131,7 @@ const mapDispatchToProps = (dispatch) => { ...@@ -130,7 +131,7 @@ const mapDispatchToProps = (dispatch) => {
fetchData: { fetchData: {
universityScholarships: (univId) => dispatch(universityScholarshipsFetchData(univId)), universityScholarships: (univId) => dispatch(universityScholarshipsFetchData(univId)),
}, },
invalidateData: (resetObj = false) => dispatch(universityScholarshipsInvalidated(true, resetObj)) invalidateData: getInvalidateDataFunction(dispatch, universityScholarshipsInvalidated, universityScholarshipsFetchDataSuccess)
}; };
}; };
......
...@@ -17,7 +17,7 @@ import LocalFloristIcon from '@material-ui/icons/LocalFlorist'; ...@@ -17,7 +17,7 @@ import LocalFloristIcon from '@material-ui/icons/LocalFlorist';
import GenericModule from '../shared/GenericModule'; import GenericModule from '../shared/GenericModule';
import Module from '../shared/Module'; import Module, { getInvalidateDataFunction } from '../shared/Module';
import dateStrToStr from '../../../utils/dateStrToStr'; import dateStrToStr from '../../../utils/dateStrToStr';
...@@ -26,6 +26,7 @@ import UniversitySemestersDatesEditor from '../editors/UniversitySemestersDatesE ...@@ -26,6 +26,7 @@ import UniversitySemestersDatesEditor from '../editors/UniversitySemestersDatesE
import { import {
universitiesSemestersDatesElFetchData, universitiesSemestersDatesElFetchData,
universitiesSemestersDatesElInvalidated, universitiesSemestersDatesElInvalidated,
universitiesSemestersDatesElFetchDataSuccess,
} from '../../../generated/actions'; } from '../../../generated/actions';
const styles = theme => ({ const styles = theme => ({
...@@ -165,7 +166,7 @@ const mapDispatchToProps = (dispatch) => { ...@@ -165,7 +166,7 @@ const mapDispatchToProps = (dispatch) => {
fetchData: { fetchData: {
universitiesSemestersDatesEl: (univId) => dispatch(universitiesSemestersDatesElFetchData(univId)), universitiesSemestersDatesEl: (univId) => dispatch(universitiesSemestersDatesElFetchData(univId)),
}, },
invalidateData: () => dispatch(universitiesSemestersDatesElInvalidated(true, true)), invalidateData: getInvalidateDataFunction(dispatch, universitiesSemestersDatesElInvalidated, universitiesSemestersDatesElFetchDataSuccess)
}; };
}; };
......
...@@ -19,4 +19,13 @@ class Module extends MyComponent { ...@@ -19,4 +19,13 @@ class Module extends MyComponent {
} }
export default Module; export default Module;
\ No newline at end of file
export function getInvalidateDataFunction(dispatch, invalidated, fetchDataSuccess) {
return (resetObj = false) => {
dispatch(invalidated(true));
if (resetObj) {
dispatch(fetchDataSuccess({}, false));
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment