Merge branch 'main' into feat/HYD-858

This commit is contained in:
Chubby Granny Chaser
2025-05-30 14:15:59 +01:00
committed by GitHub
8 changed files with 27 additions and 9 deletions

View File

@@ -514,7 +514,8 @@
"achievements_unlocked": "Achievements Unlocked",
"earned_points": "Earned points",
"show_achievements_on_profile": "Show your achievements on your profile",
"show_points_on_profile": "Show your earned points on your profile"
"show_points_on_profile": "Show your earned points on your profile",
"error_adding_friend": "Could not send friend request. Please check friend code"
},
"achievement": {
"achievement_unlocked": "Achievement unlocked",

View File

@@ -507,7 +507,8 @@
"achievements_unlocked": "Conquistas desbloqueadas",
"earned_points": "Pontos ganhos",
"show_achievements_on_profile": "Exiba suas conquistas no perfil",
"show_points_on_profile": "Exiba seus pontos ganhos no perfil"
"show_points_on_profile": "Exiba seus pontos ganhos no perfil",
"error_adding_friend": "Não foi possível enviar o pedido de amizade. Verifique o código de amizade inserido"
},
"achievement": {
"achievement_unlocked": "Conquista desbloqueada",

View File

@@ -1,5 +1,6 @@
import { registerEvent } from "../register-event";
import { gamesSublevel, levelKeys } from "@main/level";
import { HydraApi } from "@main/services";
import type { GameShop } from "@types";
const addGameToFavorites = async (
@@ -12,6 +13,8 @@ const addGameToFavorites = async (
const game = await gamesSublevel.get(gameKey);
if (!game) return;
HydraApi.put(`/profile/games/${shop}/${objectId}/favorite`).catch(() => {});
try {
await gamesSublevel.put(gameKey, {
...game,

View File

@@ -1,5 +1,6 @@
import { registerEvent } from "../register-event";
import { gamesSublevel, levelKeys } from "@main/level";
import { HydraApi } from "@main/services";
import type { GameShop } from "@types";
const removeGameFromFavorites = async (
@@ -12,6 +13,8 @@ const removeGameFromFavorites = async (
const game = await gamesSublevel.get(gameKey);
if (!game) return;
HydraApi.put(`/profile/games/${shop}/${objectId}/unfavorite`).catch(() => {});
try {
await gamesSublevel.put(gameKey, {
...game,

View File

@@ -11,14 +11,18 @@ const syncGameByObjectId = async (
return HydraApi.get<UserGameDetails>(
`/profile/games/${shop}/${objectId}`
).then(async (res) => {
const { id, playTimeInSeconds, ...rest } = res;
const { id, playTimeInSeconds, isFavorite, ...rest } = res;
const gameKey = levelKeys.game(shop, objectId);
const currentData = await gamesSublevel.get(gameKey);
await gamesSublevel.put(gameKey, {
...currentData,
...rest,
remoteId: id,
playTimeInMilliseconds: playTimeInSeconds * 1000,
favorite: isFavorite ?? currentData?.favorite,
});
return res;

View File

@@ -6,6 +6,7 @@ type ProfileGame = {
id: string;
lastTimePlayed: Date | null;
playTimeInMilliseconds: number;
isFavorite?: boolean;
} & ShopAssets;
export const mergeWithRemoteGames = async () => {
@@ -34,6 +35,7 @@ export const mergeWithRemoteGames = async () => {
remoteId: game.id,
lastTimePlayed: updatedLastTimePlayed,
playTimeInMilliseconds: updatedPlayTime,
favorite: game.isFavorite ?? localGame.favorite,
});
} else {
await gamesSublevel.put(levelKeys.game(game.shop, game.objectId), {
@@ -45,6 +47,7 @@ export const mergeWithRemoteGames = async () => {
lastTimePlayed: game.lastTimePlayed,
playTimeInMilliseconds: game.playTimeInMilliseconds,
isDeleted: false,
favorite: game.isFavorite ?? false,
});
}

View File

@@ -26,6 +26,7 @@ export const uploadGamesBatch = async () => {
playTimeInMilliseconds: Math.trunc(game.playTimeInMilliseconds),
shop: game.shop,
lastTimePlayed: game.lastTimePlayed,
isFavorite: game.favorite,
};
})
).catch(() => {});

View File

@@ -29,11 +29,10 @@ export const UserFriendModalAddFriend = ({
setIsAddingFriend(true);
sendFriendRequest(friendCode)
.then(() => {
// TODO: add validation for this input?
setFriendCode("");
})
.catch(() => {
showErrorToast("Não foi possível enviar o pedido de amizade");
showErrorToast(t("error_adding_friend"));
})
.finally(() => {
setIsAddingFriend(false);
@@ -46,8 +45,8 @@ export const UserFriendModalAddFriend = ({
};
const handleClickSeeProfile = () => {
closeModal();
if (friendCode.length === 8) {
closeModal();
navigate(`/profile/${friendCode}`);
}
};
@@ -74,16 +73,19 @@ export const UserFriendModalAddFriend = ({
});
};
const handleChangeFriendCode = (e: React.ChangeEvent<HTMLInputElement>) => {
const friendCode = e.target.value.trim().slice(0, 8);
setFriendCode(friendCode);
};
return (
<>
<div className="user-friend-modal-add-friend__actions">
<TextField
label={t("friend_code")}
value={friendCode}
minLength={8}
maxLength={8}
containerProps={{ style: { width: "100%" } }}
onChange={(e) => setFriendCode(e.target.value)}
onChange={handleChangeFriendCode}
/>
<Button
disabled={isAddingFriend}