mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-11 22:06:17 +00:00
feat: make getUserFriends throws exception
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user