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

Fixed data invalidation on unmount

parent 8583ed58
Pipeline #27363 passed with stages
in 2 minutes and 44 seconds
......@@ -50,10 +50,7 @@ export function {{obj.name}}IsLoading(bool) {
};
}
export function {{obj.name}}Invalidated(bool, resetObj=false) {
if (resetObj){
{{obj.name}}FetchDataSuccess({}, false);
}
export function {{obj.name}}Invalidated(bool) {
return {
type: {{obj.NAME}}_INVALIDATED,
invalidated: bool
......@@ -96,11 +93,7 @@ export function {{obj.name}}ElFetchHasError(bool, error) {
};
}
export function {{obj.name}}ElInvalidated(bool, resetObj=false) {
if (resetObj){
{{obj.name}}ElFetchDataSuccess({}, false);
}
export function {{obj.name}}ElInvalidated(bool) {
return {
type: {{obj.NAME}}_EL_INVALIDATED,
invalidated: bool
......
......@@ -7,7 +7,7 @@ import __pick from 'lodash/pick';
import Markdown from '../../shared/Markdown';
import Module from '../shared/Module';
import Module, { getInvalidateDataFunction } from '../shared/Module';
import GenericModule from '../shared/GenericModule';
import GenericGroupModule from '../shared/GenericGroupModule';
......@@ -17,6 +17,7 @@ import CountryDriEditor from '../editors/CountryDriEditor';
import {
countryDriFetchData,
countryDriInvalidated,
countryDriFetchDataSuccess,
} from '../../../generated/actions';
const styles = theme => ({
......@@ -110,7 +111,7 @@ const mapDispatchToProps = (dispatch) => {
fetchData: {
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';
import { connect } from "react-redux";
import __pick from 'lodash/pick';
import Module from '../shared/Module';
import Module, { getInvalidateDataFunction } from '../shared/Module';
import GenericModule from '../shared/GenericModule';
import GenericGroupModule from '../shared/GenericGroupModule';
......@@ -15,6 +15,7 @@ import CountryScholarshipsEditor from '../editors/CountryScholarshipsEditor';
import {
countryScholarshipsFetchData,
countryScholarshipsFetchDataSuccess,
countryScholarshipsInvalidated,
} from '../../../generated/actions';
......@@ -131,7 +132,7 @@ const mapDispatchToProps = (dispatch) => {
fetchData: {
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';
import Markdown from '../../shared/Markdown';
import Module from '../shared/Module';
import Module, { getInvalidateDataFunction } from '../shared/Module';
import GenericModule from '../shared/GenericModule';
import GenericGroupModule from '../shared/GenericGroupModule';
......@@ -17,6 +17,7 @@ import UniversityDriEditor from '../editors/UniversityDriEditor';
import {
universityDriFetchData,
universityDriInvalidated,
universityDriFetchDataSuccess,
} from '../../../generated/actions';
const styles = theme => ({
......@@ -113,7 +114,7 @@ const mapDispatchToProps = (dispatch) => {
fetchData: {
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';
import Markdown from '../../shared/Markdown';
import Typography from '@material-ui/core/Typography';
import Module from '../shared/Module';
import GenericModule from '../shared/GenericModule';
import TextLink from '../../other/TextLink';
import Grid from '@material-ui/core/Grid';
import Divider from '@material-ui/core/Divider';
import PhotoSizeSelectActualIcon from '@material-ui/icons/PhotoSizeSelectActual';
import GenericModule from '../shared/GenericModule';
import Module, { getInvalidateDataFunction } from '../shared/Module';
import UniversityGeneralEditor from '../editors/UniversityGeneralEditor';
import {
universitiesElFetchData,
universitiesElInvalidated,
universitiesElFetchDataSuccess,
} from '../../../generated/actions';
const styles = theme => ({
......@@ -128,7 +129,7 @@ const mapDispatchToProps = (dispatch) => {
fetchData: {
universitiesEl: (univId) => dispatch(universitiesElFetchData(univId)),
},
invalidateData: () => dispatch(universitiesElInvalidated(true, true))
invalidateData: getInvalidateDataFunction(dispatch, universitiesElInvalidated, universitiesElFetchDataSuccess)
};
};
......
......@@ -5,7 +5,7 @@ import compose from 'recompose/compose';
import { connect } from "react-redux";
import __pick from 'lodash/pick';
import Module from '../shared/Module';
import Module, { getInvalidateDataFunction } from '../shared/Module';
import GenericModule from '../shared/GenericModule';
import GenericGroupModule from '../shared/GenericGroupModule';
......@@ -16,6 +16,7 @@ import UniversityScholarshipsEditor from '../editors/UniversityScholarshipsEdito
import {
universityScholarshipsFetchData,
universityScholarshipsInvalidated,
universityScholarshipsFetchDataSuccess,
} from '../../../generated/actions';
const styles = theme => ({
......@@ -130,7 +131,7 @@ const mapDispatchToProps = (dispatch) => {
fetchData: {
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';
import GenericModule from '../shared/GenericModule';
import Module from '../shared/Module';
import Module, { getInvalidateDataFunction } from '../shared/Module';
import dateStrToStr from '../../../utils/dateStrToStr';
......@@ -26,6 +26,7 @@ import UniversitySemestersDatesEditor from '../editors/UniversitySemestersDatesE
import {
universitiesSemestersDatesElFetchData,
universitiesSemestersDatesElInvalidated,
universitiesSemestersDatesElFetchDataSuccess,
} from '../../../generated/actions';
const styles = theme => ({
......@@ -165,7 +166,7 @@ const mapDispatchToProps = (dispatch) => {
fetchData: {
universitiesSemestersDatesEl: (univId) => dispatch(universitiesSemestersDatesElFetchData(univId)),
},
invalidateData: () => dispatch(universitiesSemestersDatesElInvalidated(true, true)),
invalidateData: getInvalidateDataFunction(dispatch, universitiesSemestersDatesElInvalidated, universitiesSemestersDatesElFetchDataSuccess)
};
};
......
......@@ -19,4 +19,13 @@ class Module extends MyComponent {
}
export default Module;
\ No newline at end of file
export default Module;
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