fix: handle user not found on user-profile.context
Some checks failed
Build Renderer / build (push) Has been cancelled
Release / build (ubuntu-latest) (push) Has been cancelled
Release / build (windows-2022) (push) Has been cancelled

This commit is contained in:
Zamitto
2025-10-16 11:01:20 -03:00
parent e7ee049df5
commit 97b27a1785
2 changed files with 14 additions and 20 deletions

View File

@@ -66,10 +66,7 @@ export function UserProfileContextProvider({
const isMe = userDetails?.id === userProfile?.id;
const getHeroBackgroundFromImageUrl = async (imageUrl: string) => {
const output = await average(imageUrl, {
amount: 1,
format: "hex",
});
const output = await average(imageUrl, { amount: 1, format: "hex" });
return `linear-gradient(135deg, ${darkenColor(output as string, 0.5)}, ${darkenColor(output as string, 0.6, 0.5)})`;
};
@@ -135,9 +132,8 @@ export function UserProfileContextProvider({
getUserLibraryGames();
return window.electron.hydraApi
.get<UserProfile | null>(`/users/${userId}`)
.get<UserProfile>(`/users/${userId}`)
.then((userProfile) => {
if (userProfile) {
setUserProfile(userProfile);
if (userProfile.profileImageUrl) {
@@ -145,18 +141,16 @@ export function UserProfileContextProvider({
(color) => setHeroBackground(color)
);
}
} else {
})
.catch(() => {
showErrorToast(t("user_not_found"));
navigate(-1);
}
});
}, [navigate, getUserStats, getUserLibraryGames, showErrorToast, userId, t]);
const getBadges = useCallback(async () => {
const language = i18n.language.split("-")[0];
const params = new URLSearchParams({
locale: language,
});
const params = new URLSearchParams({ locale: language });
const badges = await window.electron.hydraApi.get<Badge[]>(
`/badges?${params.toString()}`,

View File

@@ -1047,9 +1047,9 @@
optionalDependencies:
global-agent "^3.0.0"
"@electron/node-gyp@git+https://github.com/electron/node-gyp.git#06b29aafb7708acef8b3669835c8a7857ebc92d2":
"@electron/node-gyp@https://github.com/electron/node-gyp#06b29aafb7708acef8b3669835c8a7857ebc92d2":
version "10.2.0-electron.1"
resolved "git+https://github.com/electron/node-gyp.git#06b29aafb7708acef8b3669835c8a7857ebc92d2"
resolved "https://github.com/electron/node-gyp#06b29aafb7708acef8b3669835c8a7857ebc92d2"
dependencies:
env-paths "^2.2.0"
exponential-backoff "^3.1.1"