Notifications: import target account from 'Move' notification

merge-requests/591/head
Alex Gleason 2021-07-09 17:40:15 -05:00
rodzic b6b95f06be
commit a13d31ac30
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 19 dodań i 2 usunięć

Wyświetl plik

@ -188,8 +188,25 @@ export function expandNotifications({ maxId } = {}, done = noOp) {
api(getState).get('/api/v1/notifications', { params }).then(response => {
const next = getLinks(response).refs.find(link => link.rel === 'next');
dispatch(importFetchedAccounts(response.data.map(item => item.account)));
dispatch(importFetchedStatuses(response.data.map(item => item.status).filter(status => !!status)));
const entries = response.data.reverse().reduce((acc, item) => {
if (item.account && item.account.id) {
acc.accounts[item.account.id] = item.account;
}
// Used by Move notification
if (item.target && item.target.id) {
acc.accounts[item.target.id] = item.target;
}
if (item.status && item.status.id) {
acc.statuses[item.status.id] = item.status;
}
return acc;
}, { accounts: {}, statuses: {} });
dispatch(importFetchedAccounts(Object.values(entries.accounts)));
dispatch(importFetchedStatuses(Object.values(entries.statuses)));
dispatch(expandNotificationsSuccess(response.data, next ? next.uri : null, isLoadingMore));
fetchRelatedRelationships(dispatch, response.data);