Refactor getOtherAccounts selector

This commit is contained in:
Alex Gleason 2021-07-10 04:48:12 -05:00
parent 079e269812
commit 4e3c002f8a
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
3 changed files with 16 additions and 22 deletions

View file

@ -53,17 +53,13 @@ const makeMapStateToProps = () => {
const me = state.get('me');
const soapbox = getSoapboxConfig(state);
const accounts = state.get('accounts');
const authUsers = state.getIn(['auth', 'users']);
const otherAccounts = getOtherAccounts(accounts, authUsers, me);
return {
account: getAccount(state, me),
sidebarOpen: state.get('sidebar').sidebarOpen,
donateUrl: state.getIn(['patron', 'instance', 'url']),
hasCrypto: typeof soapbox.getIn(['cryptoAddresses', 0, 'ticker']) === 'string',
isStaff: isStaff(state.getIn(['accounts', me])),
otherAccounts,
otherAccounts: getOtherAccounts(state),
};
};

View file

@ -24,13 +24,9 @@ const makeMapStateToProps = () => {
const mapStateToProps = state => {
const me = state.get('me');
const accounts = state.get('accounts');
const authUsers = state.getIn(['auth', 'users']);
const otherAccounts = getOtherAccounts(accounts, authUsers, me);
return {
account: state.getIn(['accounts', me]),
otherAccounts,
otherAccounts: getOtherAccounts(state),
isStaff: isStaff(state.getIn(['accounts', me])),
};
};

View file

@ -197,8 +197,12 @@ export const makeGetReport = () => {
};
export const makeGetOtherAccounts = () => {
return createSelector(
[(accounts, authUsers, me) => {
return createSelector([
state => state.get('accounts'),
state => state.getIn(['auth', 'users']),
state => state.get('me'),
],
(accounts, authUsers, me) => {
return authUsers
.keySeq()
.reduce((list, id) => {
@ -206,7 +210,5 @@ export const makeGetOtherAccounts = () => {
const account = accounts.get(id);
return account ? list.push(account) : list;
}, ImmutableList());
}],
otherAccounts => otherAccounts,
);
});
};