diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-04-02 22:02:38 +0200 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-04-02 22:02:38 +0200 |
commit | a23e4380b25b5ab2d7446431a046cec2a19b375a (patch) | |
tree | d15c968476b211052330f4f0fc22f20b5ced29e8 /app/assets/javascripts/components/actions/accounts.jsx | |
parent | aaa4d1b0fb896f0d5f607cca3760106399caf41b (diff) |
Avoid re-loading already loaded relationships. Also fixes issue where wrong
button would be displayed in account lists for unloaded relationships
Diffstat (limited to 'app/assets/javascripts/components/actions/accounts.jsx')
-rw-r--r-- | app/assets/javascripts/components/actions/accounts.jsx | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/app/assets/javascripts/components/actions/accounts.jsx b/app/assets/javascripts/components/actions/accounts.jsx index 05fa8e68d..37ebb9969 100644 --- a/app/assets/javascripts/components/actions/accounts.jsx +++ b/app/assets/javascripts/components/actions/accounts.jsx @@ -579,15 +579,18 @@ export function expandFollowingFail(id, error) { }; }; -export function fetchRelationships(account_ids) { +export function fetchRelationships(accountIds) { return (dispatch, getState) => { - if (account_ids.length === 0) { + const loadedRelationships = getState().get('relationships'); + const newAccountIds = accountIds.filter(id => loadedRelationships.get(id, null) === null); + + if (newAccountIds.length === 0) { return; } - dispatch(fetchRelationshipsRequest(account_ids)); + dispatch(fetchRelationshipsRequest(newAccountIds)); - api(getState).get(`/api/v1/accounts/relationships?${account_ids.map(id => `id[]=${id}`).join('&')}`).then(response => { + api(getState).get(`/api/v1/accounts/relationships?${newAccountIds.map(id => `id[]=${id}`).join('&')}`).then(response => { dispatch(fetchRelationshipsSuccess(response.data)); }).catch(error => { dispatch(fetchRelationshipsFail(error)); |