Suggestions: limit to 50 results
This commit is contained in:
parent
b64e961aca
commit
c0ea0a948d
1 changed files with 7 additions and 7 deletions
|
@ -16,10 +16,10 @@ export const SUGGESTIONS_V2_FETCH_REQUEST = 'SUGGESTIONS_V2_FETCH_REQUEST';
|
||||||
export const SUGGESTIONS_V2_FETCH_SUCCESS = 'SUGGESTIONS_V2_FETCH_SUCCESS';
|
export const SUGGESTIONS_V2_FETCH_SUCCESS = 'SUGGESTIONS_V2_FETCH_SUCCESS';
|
||||||
export const SUGGESTIONS_V2_FETCH_FAIL = 'SUGGESTIONS_V2_FETCH_FAIL';
|
export const SUGGESTIONS_V2_FETCH_FAIL = 'SUGGESTIONS_V2_FETCH_FAIL';
|
||||||
|
|
||||||
export function fetchSuggestionsV1() {
|
export function fetchSuggestionsV1(params = {}) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
dispatch({ type: SUGGESTIONS_FETCH_REQUEST, skipLoading: true });
|
dispatch({ type: SUGGESTIONS_FETCH_REQUEST, skipLoading: true });
|
||||||
return api(getState).get('/api/v1/suggestions').then(({ data: accounts }) => {
|
return api(getState).get('/api/v1/suggestions', { params }).then(({ data: accounts }) => {
|
||||||
dispatch(importFetchedAccounts(accounts));
|
dispatch(importFetchedAccounts(accounts));
|
||||||
dispatch({ type: SUGGESTIONS_FETCH_SUCCESS, accounts, skipLoading: true });
|
dispatch({ type: SUGGESTIONS_FETCH_SUCCESS, accounts, skipLoading: true });
|
||||||
return accounts;
|
return accounts;
|
||||||
|
@ -30,10 +30,10 @@ export function fetchSuggestionsV1() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fetchSuggestionsV2() {
|
export function fetchSuggestionsV2(params = {}) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
dispatch({ type: SUGGESTIONS_V2_FETCH_REQUEST, skipLoading: true });
|
dispatch({ type: SUGGESTIONS_V2_FETCH_REQUEST, skipLoading: true });
|
||||||
return api(getState).get('/api/v2/suggestions').then(({ data: suggestions }) => {
|
return api(getState).get('/api/v2/suggestions', { params }).then(({ data: suggestions }) => {
|
||||||
const accounts = suggestions.map(({ account }) => account);
|
const accounts = suggestions.map(({ account }) => account);
|
||||||
dispatch(importFetchedAccounts(accounts));
|
dispatch(importFetchedAccounts(accounts));
|
||||||
dispatch({ type: SUGGESTIONS_V2_FETCH_SUCCESS, suggestions, skipLoading: true });
|
dispatch({ type: SUGGESTIONS_V2_FETCH_SUCCESS, suggestions, skipLoading: true });
|
||||||
|
@ -45,21 +45,21 @@ export function fetchSuggestionsV2() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fetchSuggestions() {
|
export function fetchSuggestions(params = { limit: 50 }) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const instance = state.get('instance');
|
const instance = state.get('instance');
|
||||||
const features = getFeatures(instance);
|
const features = getFeatures(instance);
|
||||||
|
|
||||||
if (features.suggestionsV2) {
|
if (features.suggestionsV2) {
|
||||||
dispatch(fetchSuggestionsV2())
|
dispatch(fetchSuggestionsV2(params))
|
||||||
.then(suggestions => {
|
.then(suggestions => {
|
||||||
const accountIds = suggestions.map(({ account }) => account.id);
|
const accountIds = suggestions.map(({ account }) => account.id);
|
||||||
dispatch(fetchRelationships(accountIds));
|
dispatch(fetchRelationships(accountIds));
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
} else if (features.suggestions) {
|
} else if (features.suggestions) {
|
||||||
dispatch(fetchSuggestionsV1())
|
dispatch(fetchSuggestionsV1(params))
|
||||||
.then(accounts => {
|
.then(accounts => {
|
||||||
const accountIds = accounts.map(({ id }) => id);
|
const accountIds = accounts.map(({ id }) => id);
|
||||||
dispatch(fetchRelationships(accountIds));
|
dispatch(fetchRelationships(accountIds));
|
||||||
|
|
Loading…
Reference in a new issue