Search: resubmit when changing tabs
This commit is contained in:
parent
ad70e39143
commit
e54253d155
|
@ -36,10 +36,9 @@ export function clearSearch() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function submitSearch() {
|
export function submitSearch(filter) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const value = getState().getIn(['search', 'value']);
|
const value = getState().getIn(['search', 'value']);
|
||||||
const filter = getState().getIn(['search', 'filter'], 'accounts');
|
|
||||||
|
|
||||||
// An empty search doesn't return any results
|
// An empty search doesn't return any results
|
||||||
if (value.length === 0) {
|
if (value.length === 0) {
|
||||||
|
@ -53,7 +52,7 @@ export function submitSearch() {
|
||||||
q: value,
|
q: value,
|
||||||
resolve: true,
|
resolve: true,
|
||||||
limit: 20,
|
limit: 20,
|
||||||
type: filter,
|
type: filter || getState().getIn(['search', 'filter'], 'accounts'),
|
||||||
},
|
},
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
if (response.data.accounts) {
|
if (response.data.accounts) {
|
||||||
|
@ -93,13 +92,17 @@ export function fetchSearchFail(error) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const setFilter = filterType => dispatch => {
|
export function setFilter(filterType) {
|
||||||
dispatch({
|
return (dispatch) => {
|
||||||
type: SEARCH_FILTER_SET,
|
dispatch(submitSearch(filterType));
|
||||||
path: ['search', 'filter'],
|
|
||||||
value: filterType,
|
dispatch({
|
||||||
});
|
type: SEARCH_FILTER_SET,
|
||||||
};
|
path: ['search', 'filter'],
|
||||||
|
value: filterType,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export const expandSearch = type => (dispatch, getState) => {
|
export const expandSearch = type => (dispatch, getState) => {
|
||||||
const value = getState().getIn(['search', 'value']);
|
const value = getState().getIn(['search', 'value']);
|
||||||
|
|
Loading…
Reference in New Issue