Skip to content
Snippets Groups Projects
Commit b23e490a authored by esikkala's avatar esikkala
Browse files

Update facet values only after a succesful request

parent 21d2426d
No related branches found
No related tags found
No related merge requests found
......@@ -86,7 +86,7 @@ class Tree extends Component {
treeData: this.props.data
});
}
if (this.props.updatedFacet !== '' && this.props.updatedFacet !== this.props.property && prevProps.facetFilters != this.props.facetFilters) {
if (this.props.updatedFacet !== null && this.props.updatedFacet !== this.props.property && prevProps.facetFilters != this.props.facetFilters) {
// console.log(`fetching new values for ${this.props.property}`)
this.props.fetchFacet(this.props.resultClass, this.props.property, this.props.sortBy, this.props.sortDirection);
}
......
......@@ -63,8 +63,7 @@ export const INITIAL_STATE = {
source: new Set(),
language: new Set(),
},
updatedFacet: '',
fetching: false
updatedFacet: null,
};
const manuscriptsFacets = (state = INITIAL_STATE, action) => {
......@@ -81,16 +80,10 @@ const manuscriptsFacets = (state = INITIAL_STATE, action) => {
case FETCH_FACET:
return {
...state,
fetching: true,
facets: {
...state.facets,
[ action.id ]: {
...state.facets[action.id],
distinctValueCount: 0,
values: [],
flatValues: [],
sortBy: action.sortBy,
sortDirection: action.sortDirection,
isFetching: true
}
}
......@@ -104,12 +97,18 @@ const manuscriptsFacets = (state = INITIAL_STATE, action) => {
...state.facets[action.id],
isFetching: false,
}
}
},
filters: {
productionPlace: new Set(),
author: new Set(),
source: new Set(),
language: new Set(),
},
updatedFacet: '',
};
case UPDATE_FACET:
return {
...state,
fetching: false,
facets: {
...state.facets,
[ action.id ]: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment