fix: linting error. Feat: hide pin button if user is not logged in

This commit is contained in:
Moyasee
2025-09-24 14:11:44 +03:00
parent 092af7e421
commit f9d51ed33d
5 changed files with 29 additions and 29 deletions

View File

@@ -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);

View File

@@ -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) =>

View File

@@ -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: (

View File

@@ -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)}

View File

@@ -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;