mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 00:33:49 +03:00
feat: add getUserFriends event
This commit is contained in:
parent
380143c780
commit
010f07373d
@ -43,6 +43,7 @@ import "./auth/sign-out";
|
||||
import "./auth/open-auth-window";
|
||||
import "./auth/get-session-hash";
|
||||
import "./user/get-user";
|
||||
import "./user/get-user-friends";
|
||||
import "./profile/get-friend-requests";
|
||||
import "./profile/get-me";
|
||||
import "./profile/update-friend-request";
|
||||
|
@ -8,21 +8,23 @@ export const getUserFriends = async (
|
||||
take: number,
|
||||
skip: number
|
||||
): Promise<UserFriends> => {
|
||||
const loggedUser = await userAuthRepository.findOne({ where: { id: 1 } });
|
||||
try {
|
||||
const loggedUser = await userAuthRepository.findOne({ where: { id: 1 } });
|
||||
|
||||
if (loggedUser?.userId == userId) {
|
||||
return HydraApi.get(`/profile/friends`, { take, skip }).catch(
|
||||
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: [] };
|
||||
}
|
||||
|
||||
return HydraApi.get(`/user/${userId}/friends`, { take, skip }).catch(
|
||||
(_err) => {
|
||||
return { totalFriends: 0, friends: [] };
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const getUserFriendsEvent = async (
|
||||
|
@ -145,6 +145,7 @@ contextBridge.exposeInMainWorld("electron", {
|
||||
|
||||
/* User */
|
||||
getUser: (userId: string) => ipcRenderer.invoke("getUser", userId),
|
||||
getUserFriends: (userId: string) => ipcRenderer.invoke("getUserFriends", userId),
|
||||
|
||||
/* Auth */
|
||||
signOut: () => ipcRenderer.invoke("signOut"),
|
||||
|
2
src/renderer/src/declaration.d.ts
vendored
2
src/renderer/src/declaration.d.ts
vendored
@ -16,6 +16,7 @@ import type {
|
||||
UserProfile,
|
||||
FriendRequest,
|
||||
FriendRequestAction,
|
||||
UserFriends,
|
||||
} from "@types";
|
||||
import type { DiskSpace } from "check-disk-space";
|
||||
|
||||
@ -127,6 +128,7 @@ declare global {
|
||||
|
||||
/* User */
|
||||
getUser: (userId: string) => Promise<UserProfile | null>;
|
||||
getUserFriends: (userId: string) => Promise<UserFriends>;
|
||||
|
||||
/* Profile */
|
||||
getMe: () => Promise<UserProfile | null>;
|
||||
|
Loading…
Reference in New Issue
Block a user