Importer: remove the extremely stupid pushUnique function

This commit is contained in:
Alex Gleason 2022-01-24 14:29:30 -06:00
parent 93e7efba05
commit aebc653bd9
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -13,12 +13,6 @@ export const STATUSES_IMPORT = 'STATUSES_IMPORT';
export const POLLS_IMPORT = 'POLLS_IMPORT';
export const ACCOUNT_FETCH_FAIL_FOR_USERNAME_LOOKUP = 'ACCOUNT_FETCH_FAIL_FOR_USERNAME_LOOKUP';
function pushUnique(array, object) {
if (array.every(element => element.id !== object.id)) {
array.push(object);
}
}
export function importAccount(account) {
return { type: ACCOUNT_IMPORT, account };
}
@ -49,7 +43,7 @@ export function importFetchedAccounts(accounts) {
function processAccount(account) {
if (!account.id) return;
pushUnique(normalAccounts, normalizeAccount(account));
normalAccounts.push(normalizeAccount(account));
if (account.moved) {
processAccount(account.moved);
@ -122,8 +116,8 @@ export function importFetchedStatuses(statuses) {
const normalOldStatus = getState().getIn(['statuses', status.id]);
const expandSpoilers = getSettings(getState()).get('expandSpoilers');
pushUnique(normalStatuses, normalizeStatus(status, normalOldStatus, expandSpoilers));
pushUnique(accounts, status.account);
normalStatuses.push(normalizeStatus(status, normalOldStatus, expandSpoilers));
accounts.push(status.account);
if (status.reblog && status.reblog.id) {
processStatus(status.reblog);
@ -139,7 +133,7 @@ export function importFetchedStatuses(statuses) {
}
if (status.poll && status.poll.id) {
pushUnique(polls, normalizePoll(status.poll));
polls.push(normalizePoll(status.poll));
}
}