Make relationships load faster

Import pleroma.relationships when the account loads
tl-language-filters
Alex Gleason 2020-07-04 20:15:20 -05:00
rodzic d31946775c
commit 61deb1237d
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 21 dodań i 0 usunięć

Wyświetl plik

@ -13,6 +13,10 @@ import {
ACCOUNT_UNPIN_SUCCESS,
RELATIONSHIPS_FETCH_SUCCESS,
} from '../actions/accounts';
import {
ACCOUNT_IMPORT,
ACCOUNTS_IMPORT,
} from '../actions/importer';
import {
DOMAIN_BLOCK_SUCCESS,
DOMAIN_UNBLOCK_SUCCESS,
@ -37,10 +41,27 @@ const setDomainBlocking = (state, accounts, blocking) => {
});
};
const importPleromaAccount = (state, account) => {
if (!account.pleroma) return state;
return normalizeRelationship(state, account.pleroma.relationship);
};
const importPleromaAccounts = (state, accounts) => {
accounts.forEach(account => {
state = importPleromaAccount(state, account);
});
return state;
};
const initialState = ImmutableMap();
export default function relationships(state = initialState, action) {
switch(action.type) {
case ACCOUNT_IMPORT:
return importPleromaAccount(state, action.account);
case ACCOUNTS_IMPORT:
return importPleromaAccounts(state, action.accounts);
case ACCOUNT_FOLLOW_REQUEST:
return state.setIn([action.id, action.locked ? 'requested' : 'following'], true);
case ACCOUNT_FOLLOW_FAIL: