mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-20 01:33:56 +00:00
fix: linting error. Feat: hide pin button if user is not logged in
This commit is contained in:
@@ -9,19 +9,19 @@ const getUserLibrary = async (
|
||||
skip?: number
|
||||
): Promise<UserLibraryResponse | null> => {
|
||||
const params = new URLSearchParams();
|
||||
|
||||
|
||||
if (take !== undefined) {
|
||||
params.append('take', take.toString());
|
||||
params.append("take", take.toString());
|
||||
}
|
||||
|
||||
|
||||
if (skip !== undefined) {
|
||||
params.append('skip', skip.toString());
|
||||
params.append("skip", skip.toString());
|
||||
}
|
||||
|
||||
|
||||
const queryString = params.toString();
|
||||
const url = `/users/${userId}/library${queryString ? `?${queryString}` : ''}`;
|
||||
|
||||
const url = `/users/${userId}/library${queryString ? `?${queryString}` : ""}`;
|
||||
|
||||
return HydraApi.get<UserLibraryResponse>(url).catch(() => null);
|
||||
};
|
||||
|
||||
registerEvent("getUserLibrary", getUserLibrary);
|
||||
registerEvent("getUserLibrary", getUserLibrary);
|
||||
|
||||
@@ -370,7 +370,8 @@ contextBridge.exposeInMainWorld("electron", {
|
||||
|
||||
/* User */
|
||||
getUser: (userId: string) => ipcRenderer.invoke("getUser", userId),
|
||||
getUserLibrary: (userId: string, take?: number, skip?: number) => ipcRenderer.invoke("getUserLibrary", userId, take, skip),
|
||||
getUserLibrary: (userId: string, take?: number, skip?: number) =>
|
||||
ipcRenderer.invoke("getUserLibrary", userId, take, skip),
|
||||
blockUser: (userId: string) => ipcRenderer.invoke("blockUser", userId),
|
||||
unblockUser: (userId: string) => ipcRenderer.invoke("unblockUser", userId),
|
||||
getUserFriends: (userId: string, take: number, skip: number) =>
|
||||
|
||||
7
src/renderer/src/declaration.d.ts
vendored
7
src/renderer/src/declaration.d.ts
vendored
@@ -37,7 +37,6 @@ import type {
|
||||
ShopDetailsWithAssets,
|
||||
AchievementCustomNotificationPosition,
|
||||
AchievementNotificationInfo,
|
||||
UserGame,
|
||||
UserLibraryResponse,
|
||||
} from "@types";
|
||||
import type { AxiosProgressEvent } from "axios";
|
||||
@@ -291,7 +290,11 @@ declare global {
|
||||
|
||||
/* User */
|
||||
getUser: (userId: string) => Promise<UserProfile | null>;
|
||||
getUserLibrary: (userId: string, take?: number, skip?: number) => Promise<UserLibraryResponse>;
|
||||
getUserLibrary: (
|
||||
userId: string,
|
||||
take?: number,
|
||||
skip?: number
|
||||
) => Promise<UserLibraryResponse>;
|
||||
blockUser: (userId: string) => Promise<void>;
|
||||
unblockUser: (userId: string) => Promise<void>;
|
||||
getUserFriends: (
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
PlusCircleIcon,
|
||||
} from "@primer/octicons-react";
|
||||
import { Button } from "@renderer/components";
|
||||
import { useDownload, useLibrary, useToast } from "@renderer/hooks";
|
||||
import { useDownload, useLibrary, useToast, useUserDetails } from "@renderer/hooks";
|
||||
import { useContext, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { gameDetailsContext } from "@renderer/context";
|
||||
@@ -21,6 +21,7 @@ export function HeroPanelActions() {
|
||||
useState(false);
|
||||
|
||||
const { isGameDeleting } = useDownload();
|
||||
const { userDetails } = useUserDetails();
|
||||
|
||||
const {
|
||||
game,
|
||||
@@ -223,14 +224,16 @@ export function HeroPanelActions() {
|
||||
{game.favorite ? <HeartFillIcon /> : <HeartIcon />}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
onClick={toggleGamePinned}
|
||||
theme="outline"
|
||||
disabled={deleting}
|
||||
className="hero-panel-actions__action"
|
||||
>
|
||||
{game.pinned ? <PinSlashIcon /> : <PinIcon />}
|
||||
</Button>
|
||||
{userDetails && (
|
||||
<Button
|
||||
onClick={toggleGamePinned}
|
||||
theme="outline"
|
||||
disabled={deleting}
|
||||
className="hero-panel-actions__action"
|
||||
>
|
||||
{game.pinned ? <PinSlashIcon /> : <PinIcon />}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<Button
|
||||
onClick={() => setShowGameOptionsModal(true)}
|
||||
|
||||
@@ -16,13 +16,8 @@ import "./profile-content.scss";
|
||||
const GAME_STATS_ANIMATION_DURATION_IN_MS = 3500;
|
||||
|
||||
export function ProfileContent() {
|
||||
const {
|
||||
userProfile,
|
||||
isMe,
|
||||
userStats,
|
||||
libraryGames,
|
||||
pinnedGames,
|
||||
} = useContext(userProfileContext);
|
||||
const { userProfile, isMe, userStats, libraryGames, pinnedGames } =
|
||||
useContext(userProfileContext);
|
||||
const [statsIndex, setStatsIndex] = useState(0);
|
||||
const [isAnimationRunning, setIsAnimationRunning] = useState(true);
|
||||
const statsAnimation = useRef(-1);
|
||||
@@ -74,8 +69,6 @@ export function ProfileContent() {
|
||||
return userProfile?.relation?.status === "ACCEPTED";
|
||||
}, [userProfile]);
|
||||
|
||||
|
||||
|
||||
const content = useMemo(() => {
|
||||
if (!userProfile) return null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user