refactor: friendship as ids
This commit is contained in:
parent
619292b853
commit
df7a1f163b
|
@ -49,15 +49,10 @@ class User extends BaseModel {
|
|||
},
|
||||
});
|
||||
const friendList = await Promise.all(
|
||||
friendships.map(async ({adderId, addeeId, state}) => {
|
||||
const otherId = adderId === this.id ? addeeId : adderId;
|
||||
const user = await User.findByPk(otherId);
|
||||
return {
|
||||
id: user.id,
|
||||
redditUsername: user.redditUsername,
|
||||
state,
|
||||
};
|
||||
}),
|
||||
friendships.map(async ({adderId, addeeId, state}) => ([
|
||||
adderId === this.id ? addeeId : adderId,
|
||||
state,
|
||||
])),
|
||||
);
|
||||
return friendList.reduce((r, friend) => ({...r, [friend.id]: friend}), {});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user