From c0ea0a948dbdb1a103b9044d3edfe3c80de94906 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 16 Mar 2022 16:01:36 -0500 Subject: [PATCH] Suggestions: limit to 50 results --- app/soapbox/actions/suggestions.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/soapbox/actions/suggestions.js b/app/soapbox/actions/suggestions.js index d896e6e07..0221b3a05 100644 --- a/app/soapbox/actions/suggestions.js +++ b/app/soapbox/actions/suggestions.js @@ -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_FAIL = 'SUGGESTIONS_V2_FETCH_FAIL'; -export function fetchSuggestionsV1() { +export function fetchSuggestionsV1(params = {}) { return (dispatch, getState) => { 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({ type: SUGGESTIONS_FETCH_SUCCESS, accounts, skipLoading: true }); return accounts; @@ -30,10 +30,10 @@ export function fetchSuggestionsV1() { }; } -export function fetchSuggestionsV2() { +export function fetchSuggestionsV2(params = {}) { return (dispatch, getState) => { 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); dispatch(importFetchedAccounts(accounts)); 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) => { const state = getState(); const instance = state.get('instance'); const features = getFeatures(instance); if (features.suggestionsV2) { - dispatch(fetchSuggestionsV2()) + dispatch(fetchSuggestionsV2(params)) .then(suggestions => { const accountIds = suggestions.map(({ account }) => account.id); dispatch(fetchRelationships(accountIds)); }) .catch(() => {}); } else if (features.suggestions) { - dispatch(fetchSuggestionsV1()) + dispatch(fetchSuggestionsV1(params)) .then(accounts => { const accountIds = accounts.map(({ id }) => id); dispatch(fetchRelationships(accountIds));