mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: correctly get own friends
This commit is contained in:
parent
e642bf71b1
commit
380143c780
1 changed files with 12 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
|||
import { userAuthRepository } from "@main/repository";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { HydraApi } from "@main/services";
|
||||
import { UserFriends } from "@types";
|
||||
|
@ -7,9 +8,19 @@ export const getUserFriends = async (
|
|||
take: number,
|
||||
skip: number
|
||||
): Promise<UserFriends> => {
|
||||
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: [] } as UserFriends;
|
||||
return { totalFriends: 0, friends: [] };
|
||||
}
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue