Updated fetchRelationships for accounts and importing
• Updated: - fetchRelationships for accounts and importing relationships on timeline fetches
This commit is contained in:
parent
4ca59477d5
commit
6f12f94c8c
@ -577,7 +577,10 @@ export function fetchRelationships(accountIds) {
|
||||
if (!me) return;
|
||||
|
||||
const loadedRelationships = getState().get('relationships');
|
||||
const newAccountIds = accountIds.filter(id => loadedRelationships.get(id, null) === null);
|
||||
let newAccountIds = accountIds.filter((id) => {
|
||||
if (id === me) return false
|
||||
return loadedRelationships.get(id, null) === null
|
||||
})
|
||||
|
||||
if (newAccountIds.length === 0) {
|
||||
return;
|
||||
@ -586,6 +589,9 @@ export function fetchRelationships(accountIds) {
|
||||
if (me === firstId) return;
|
||||
}
|
||||
|
||||
// Unique
|
||||
newAccountIds = Array.from(new Set(newAccountIds))
|
||||
|
||||
dispatch(fetchRelationshipsRequest(newAccountIds));
|
||||
|
||||
api(getState).get(`/api/v1/accounts/relationships?${newAccountIds.map(id => `id[]=${id}`).join('&')}`).then(response => {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Map as ImmutableMap, List as ImmutableList, toJS } from 'immutable';
|
||||
import { importFetchedStatus, importFetchedStatuses } from './importer';
|
||||
import api, { getLinks } from '../api';
|
||||
import { Map as ImmutableMap, List as ImmutableList, toJS } from 'immutable';
|
||||
import { fetchRelationships } from './accounts'
|
||||
|
||||
export const TIMELINE_UPDATE = 'TIMELINE_UPDATE';
|
||||
export const TIMELINE_DELETE = 'TIMELINE_DELETE';
|
||||
@ -18,6 +19,13 @@ export const TIMELINE_DISCONNECT = 'TIMELINE_DISCONNECT';
|
||||
|
||||
export const MAX_QUEUED_ITEMS = 40;
|
||||
|
||||
const fetchStatusesAccountsRelationships = (dispatch, statuses) => {
|
||||
const accountIds = statuses.map(item => item.account.id)
|
||||
if (accountIds.length > 0) {
|
||||
dispatch(fetchRelationships(accountIds));
|
||||
}
|
||||
}
|
||||
|
||||
export function updateTimeline(timeline, status, accept) {
|
||||
return dispatch => {
|
||||
if (typeof accept === 'function' && !accept(status)) {
|
||||
@ -148,6 +156,7 @@ export function expandTimeline(timelineId, path, params = {}, done = noOp) {
|
||||
const next = getLinks(response).refs.find(link => link.rel === 'next');
|
||||
dispatch(importFetchedStatuses(response.data));
|
||||
dispatch(expandTimelineSuccess(timelineId, response.data, next ? next.uri : null, response.code === 206, isLoadingRecent, isLoadingMore));
|
||||
fetchStatusesAccountsRelationships(dispatch, response.data)
|
||||
done();
|
||||
}).catch(error => {
|
||||
dispatch(expandTimelineFail(timelineId, error, isLoadingMore));
|
||||
|
Loading…
x
Reference in New Issue
Block a user