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(
|
const friendList = await Promise.all(
|
||||||
friendships.map(async ({adderId, addeeId, state}) => {
|
friendships.map(async ({adderId, addeeId, state}) => ([
|
||||||
const otherId = adderId === this.id ? addeeId : adderId;
|
adderId === this.id ? addeeId : adderId,
|
||||||
const user = await User.findByPk(otherId);
|
state,
|
||||||
return {
|
])),
|
||||||
id: user.id,
|
|
||||||
redditUsername: user.redditUsername,
|
|
||||||
state,
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
return friendList.reduce((r, friend) => ({...r, [friend.id]: friend}), {});
|
return friendList.reduce((r, friend) => ({...r, [friend.id]: friend}), {});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user