mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-29 05:41:03 +00:00
feat:profile endpoint change and complete pinning functionality
This commit is contained in:
27
src/main/events/user/get-user-library.ts
Normal file
27
src/main/events/user/get-user-library.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { registerEvent } from "../register-event";
|
||||
import { HydraApi } from "@main/services";
|
||||
import type { UserLibraryResponse } from "@types";
|
||||
|
||||
const getUserLibrary = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
userId: string,
|
||||
take?: number,
|
||||
skip?: number
|
||||
): Promise<UserLibraryResponse | null> => {
|
||||
const params = new URLSearchParams();
|
||||
|
||||
if (take !== undefined) {
|
||||
params.append('take', take.toString());
|
||||
}
|
||||
|
||||
if (skip !== undefined) {
|
||||
params.append('skip', skip.toString());
|
||||
}
|
||||
|
||||
const queryString = params.toString();
|
||||
const url = `/users/${userId}/library${queryString ? `?${queryString}` : ''}`;
|
||||
|
||||
return HydraApi.get<UserLibraryResponse>(url).catch(() => null);
|
||||
};
|
||||
|
||||
registerEvent("getUserLibrary", getUserLibrary);
|
||||
Reference in New Issue
Block a user