mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: make getUserFriends throws exception
This commit is contained in:
parent
4dcd97bce8
commit
f631cd3013
2 changed files with 8 additions and 16 deletions
|
@ -8,23 +8,13 @@ export const getUserFriends = async (
|
|||
take: number,
|
||||
skip: number
|
||||
): Promise<UserFriends> => {
|
||||
try {
|
||||
const loggedUser = await userAuthRepository.findOne({ where: { id: 1 } });
|
||||
const loggedUser = await userAuthRepository.findOne({ where: { id: 1 } });
|
||||
|
||||
if (loggedUser?.userId == userId) {
|
||||
return HydraApi.get(`/profile/friends`, { take, skip }).catch((_err) => {
|
||||
return { totalFriends: 0, friends: [] };
|
||||
});
|
||||
}
|
||||
|
||||
return HydraApi.get(`/user/${userId}/friends`, { take, skip }).catch(
|
||||
(_err) => {
|
||||
return { totalFriends: 0, friends: [] };
|
||||
}
|
||||
);
|
||||
} catch (err) {
|
||||
return { totalFriends: 0, friends: [] };
|
||||
if (loggedUser?.userId === userId) {
|
||||
return HydraApi.get(`/profile/friends`, { take, skip });
|
||||
}
|
||||
|
||||
return HydraApi.get(`/user/${userId}/friends`, { take, skip });
|
||||
};
|
||||
|
||||
const getUserFriendsEvent = async (
|
||||
|
|
|
@ -13,7 +13,9 @@ const getUser = async (
|
|||
try {
|
||||
const [profile, friends] = await Promise.all([
|
||||
HydraApi.get(`/user/${userId}`),
|
||||
getUserFriends(userId, 12, 0),
|
||||
getUserFriends(userId, 12, 0).catch(() => {
|
||||
return { totalFriends: 0, friends: [] };
|
||||
}),
|
||||
]);
|
||||
|
||||
const recentGames = await Promise.all(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue