pl-fe: avoiding processing the same account multiple times

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2024-09-26 23:38:16 +02:00
parent 567bc33e96
commit 2f17eefba1

View file

@ -111,7 +111,7 @@ const isBroken = (status: BaseStatus) => {
};
const importFetchedStatuses = (statuses: Array<Omit<BaseStatus, 'account'> & { account: BaseAccount | null }>) => (dispatch: AppDispatch) => {
const accounts: Array<BaseAccount> = [];
const accounts: Record<string, BaseAccount> = {};
const normalStatuses: Array<BaseStatus> = [];
const polls: Array<Poll> = [];
@ -122,7 +122,7 @@ const importFetchedStatuses = (statuses: Array<Omit<BaseStatus, 'account'> & { a
normalStatuses.push(status);
if (status.account !== null) accounts.push(status.account);
accounts[status.account.id] = status.account;
// if (status.accounts) {
// accounts.push(...status.accounts);
// }
@ -144,7 +144,7 @@ const importFetchedStatuses = (statuses: Array<Omit<BaseStatus, 'account'> & { a
(statuses as Array<BaseStatus>).forEach(processStatus);
dispatch(importPolls(polls));
dispatch(importFetchedAccounts(accounts));
dispatch(importFetchedAccounts(Object.values(accounts)));
dispatch(importStatuses(normalStatuses));
};