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/open-auth-window";
|
||||||
import "./auth/get-session-hash";
|
import "./auth/get-session-hash";
|
||||||
import "./user/get-user";
|
import "./user/get-user";
|
||||||
|
import "./user/get-user-friends";
|
||||||
import "./profile/get-friend-requests";
|
import "./profile/get-friend-requests";
|
||||||
import "./profile/get-me";
|
import "./profile/get-me";
|
||||||
import "./profile/update-friend-request";
|
import "./profile/update-friend-request";
|
||||||
|
@ -8,21 +8,23 @@ export const getUserFriends = async (
|
|||||||
take: number,
|
take: number,
|
||||||
skip: number
|
skip: number
|
||||||
): Promise<UserFriends> => {
|
): Promise<UserFriends> => {
|
||||||
const loggedUser = await userAuthRepository.findOne({ where: { id: 1 } });
|
try {
|
||||||
|
const loggedUser = await userAuthRepository.findOne({ where: { id: 1 } });
|
||||||
|
|
||||||
if (loggedUser?.userId == userId) {
|
if (loggedUser?.userId == userId) {
|
||||||
return HydraApi.get(`/profile/friends`, { take, skip }).catch(
|
return HydraApi.get(`/profile/friends`, { take, skip }).catch((_err) => {
|
||||||
|
return { totalFriends: 0, friends: [] };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return HydraApi.get(`/user/${userId}/friends`, { take, skip }).catch(
|
||||||
(_err) => {
|
(_err) => {
|
||||||
return { totalFriends: 0, friends: [] };
|
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 (
|
const getUserFriendsEvent = async (
|
||||||
|
@ -145,6 +145,7 @@ contextBridge.exposeInMainWorld("electron", {
|
|||||||
|
|
||||||
/* User */
|
/* User */
|
||||||
getUser: (userId: string) => ipcRenderer.invoke("getUser", userId),
|
getUser: (userId: string) => ipcRenderer.invoke("getUser", userId),
|
||||||
|
getUserFriends: (userId: string) => ipcRenderer.invoke("getUserFriends", userId),
|
||||||
|
|
||||||
/* Auth */
|
/* Auth */
|
||||||
signOut: () => ipcRenderer.invoke("signOut"),
|
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,
|
UserProfile,
|
||||||
FriendRequest,
|
FriendRequest,
|
||||||
FriendRequestAction,
|
FriendRequestAction,
|
||||||
|
UserFriends,
|
||||||
} from "@types";
|
} from "@types";
|
||||||
import type { DiskSpace } from "check-disk-space";
|
import type { DiskSpace } from "check-disk-space";
|
||||||
|
|
||||||
@ -127,6 +128,7 @@ declare global {
|
|||||||
|
|
||||||
/* User */
|
/* User */
|
||||||
getUser: (userId: string) => Promise<UserProfile | null>;
|
getUser: (userId: string) => Promise<UserProfile | null>;
|
||||||
|
getUserFriends: (userId: string) => Promise<UserFriends>;
|
||||||
|
|
||||||
/* Profile */
|
/* Profile */
|
||||||
getMe: () => Promise<UserProfile | null>;
|
getMe: () => Promise<UserProfile | null>;
|
||||||
|
Loading…
Reference in New Issue
Block a user