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,
|
take: number,
|
||||||
skip: number
|
skip: number
|
||||||
): Promise<UserFriends> => {
|
): Promise<UserFriends> => {
|
||||||
try {
|
|
||||||
const loggedUser = await userAuthRepository.findOne({ where: { id: 1 } });
|
const loggedUser = await userAuthRepository.findOne({ where: { id: 1 } });
|
||||||
|
|
||||||
if (loggedUser?.userId == userId) {
|
if (loggedUser?.userId === userId) {
|
||||||
return HydraApi.get(`/profile/friends`, { take, skip }).catch((_err) => {
|
return HydraApi.get(`/profile/friends`, { take, skip });
|
||||||
return { totalFriends: 0, friends: [] };
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return HydraApi.get(`/user/${userId}/friends`, { take, skip }).catch(
|
return HydraApi.get(`/user/${userId}/friends`, { take, skip });
|
||||||
(_err) => {
|
|
||||||
return { totalFriends: 0, friends: [] };
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} catch (err) {
|
|
||||||
return { totalFriends: 0, friends: [] };
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getUserFriendsEvent = async (
|
const getUserFriendsEvent = async (
|
||||||
|
|
|
@ -13,7 +13,9 @@ const getUser = async (
|
||||||
try {
|
try {
|
||||||
const [profile, friends] = await Promise.all([
|
const [profile, friends] = await Promise.all([
|
||||||
HydraApi.get(`/user/${userId}`),
|
HydraApi.get(`/user/${userId}`),
|
||||||
getUserFriends(userId, 12, 0),
|
getUserFriends(userId, 12, 0).catch(() => {
|
||||||
|
return { totalFriends: 0, friends: [] };
|
||||||
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const recentGames = await Promise.all(
|
const recentGames = await Promise.all(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue