mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-24 11:21:02 +00:00
feat:profile endpoint change and complete pinning functionality
This commit is contained in:
@@ -66,6 +66,7 @@ import "./auth/sign-out";
|
||||
import "./auth/open-auth-window";
|
||||
import "./auth/get-session-hash";
|
||||
import "./user/get-user";
|
||||
import "./user/get-user-library";
|
||||
import "./user/get-blocked-users";
|
||||
import "./user/block-user";
|
||||
import "./user/unblock-user";
|
||||
|
||||
@@ -19,10 +19,11 @@ const addGameToPinned = async (
|
||||
await gamesSublevel.put(gameKey, {
|
||||
...game,
|
||||
pinned: true,
|
||||
pinnedDate: new Date(),
|
||||
});
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to update game pinned status: ${error}`);
|
||||
}
|
||||
};
|
||||
|
||||
registerEvent("addGameToPinned", addGameToPinned);
|
||||
registerEvent("addGameToPinned", addGameToPinned);
|
||||
|
||||
@@ -19,10 +19,11 @@ const removeGameFromPinned = async (
|
||||
await gamesSublevel.put(gameKey, {
|
||||
...game,
|
||||
pinned: false,
|
||||
pinnedDate: null,
|
||||
});
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to update game pinned status: ${error}`);
|
||||
}
|
||||
};
|
||||
|
||||
registerEvent("removeGameFromPinned", removeGameFromPinned);
|
||||
registerEvent("removeGameFromPinned", removeGameFromPinned);
|
||||
|
||||
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