|
|
|
@ -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)); |
|
|
|
|