mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-29 22:01:03 +00:00
feat: added pin/unpin to the game card in profile
This commit is contained in:
@@ -35,7 +35,8 @@ export function UserLibraryGameCard({
|
|||||||
onMouseEnter,
|
onMouseEnter,
|
||||||
onMouseLeave,
|
onMouseLeave,
|
||||||
}: UserLibraryGameCardProps) {
|
}: UserLibraryGameCardProps) {
|
||||||
const { userProfile, isMe, getUserLibraryGames } = useContext(userProfileContext);
|
const { userProfile, isMe, getUserLibraryGames } =
|
||||||
|
useContext(userProfileContext);
|
||||||
const { t } = useTranslation("user_profile");
|
const { t } = useTranslation("user_profile");
|
||||||
const { t: tGame } = useTranslation("game_details");
|
const { t: tGame } = useTranslation("game_details");
|
||||||
const { numberFormatter } = useFormat();
|
const { numberFormatter } = useFormat();
|
||||||
@@ -99,18 +100,22 @@ export function UserLibraryGameCard({
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (game.isPinned) {
|
if (game.isPinned) {
|
||||||
await window.electron.removeGameFromPinned(game.shop, game.objectId).then(() => {
|
await window.electron
|
||||||
showSuccessToast(tGame("game_removed_from_pinned"));
|
.removeGameFromPinned(game.shop, game.objectId)
|
||||||
});
|
.then(() => {
|
||||||
|
showSuccessToast(tGame("game_removed_from_pinned"));
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
await window.electron.addGameToPinned(game.shop, game.objectId).then(() => {
|
await window.electron
|
||||||
showSuccessToast(tGame("game_added_to_pinned"));
|
.addGameToPinned(game.shop, game.objectId)
|
||||||
});
|
.then(() => {
|
||||||
|
showSuccessToast(tGame("game_added_to_pinned"));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a small delay to allow server synchronization before refreshing
|
// Add a small delay to allow server synchronization before refreshing
|
||||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||||
|
|
||||||
// Refresh the library games to update the UI
|
// Refresh the library games to update the UI
|
||||||
await getUserLibraryGames();
|
await getUserLibraryGames();
|
||||||
} finally {
|
} finally {
|
||||||
@@ -149,7 +154,11 @@ export function UserLibraryGameCard({
|
|||||||
}}
|
}}
|
||||||
disabled={isPinning}
|
disabled={isPinning}
|
||||||
>
|
>
|
||||||
{game.isPinned ? <PinSlashIcon size={12} /> : <PinIcon size={12} />}
|
{game.isPinned ? (
|
||||||
|
<PinSlashIcon size={12} />
|
||||||
|
) : (
|
||||||
|
<PinIcon size={12} />
|
||||||
|
)}
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user