Simplify makeGetAccount further
This commit is contained in:
parent
8955a56c27
commit
f46374fdac
1 changed files with 1 additions and 12 deletions
|
@ -23,23 +23,12 @@ const normalizeId = (id: any): string => typeof id === 'string' ? id : '';
|
||||||
|
|
||||||
const getAccountBase = (state: RootState, id: string) => state.accounts.get(id);
|
const getAccountBase = (state: RootState, id: string) => state.accounts.get(id);
|
||||||
const getAccountRelationship = (state: RootState, id: string) => state.relationships.get(id);
|
const getAccountRelationship = (state: RootState, id: string) => state.relationships.get(id);
|
||||||
const getAccountMoved = (state: RootState, id: string) => state.accounts.get(state.accounts.get(id)?.moved || '');
|
|
||||||
const getAccountMeta = (state: RootState, id: string) => state.accounts_meta.get(id);
|
|
||||||
const getAccountAdminData = (state: RootState, id: string) => state.admin.users.get(id);
|
|
||||||
const getAccountPatron = (state: RootState, id: string) => {
|
|
||||||
const url = state.accounts.get(id)?.url;
|
|
||||||
return url ? state.patron.accounts.get(url) : null;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const makeGetAccount = () => {
|
export const makeGetAccount = () => {
|
||||||
return createSelector([
|
return createSelector([
|
||||||
getAccountBase,
|
getAccountBase,
|
||||||
getAccountRelationship,
|
getAccountRelationship,
|
||||||
getAccountMoved,
|
], (base, relationship) => {
|
||||||
getAccountMeta,
|
|
||||||
getAccountAdminData,
|
|
||||||
getAccountPatron,
|
|
||||||
], (base, relationship, moved, meta, admin, patron) => {
|
|
||||||
if (!base) return null;
|
if (!base) return null;
|
||||||
base.relationship = base.relationship ?? relationship;
|
base.relationship = base.relationship ?? relationship;
|
||||||
return base;
|
return base;
|
||||||
|
|
Loading…
Reference in a new issue