mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-11 13:56:16 +00:00
fix: handle user not found on user-profile.context
This commit is contained in:
@@ -66,10 +66,7 @@ export function UserProfileContextProvider({
|
|||||||
const isMe = userDetails?.id === userProfile?.id;
|
const isMe = userDetails?.id === userProfile?.id;
|
||||||
|
|
||||||
const getHeroBackgroundFromImageUrl = async (imageUrl: string) => {
|
const getHeroBackgroundFromImageUrl = async (imageUrl: string) => {
|
||||||
const output = await average(imageUrl, {
|
const output = await average(imageUrl, { amount: 1, format: "hex" });
|
||||||
amount: 1,
|
|
||||||
format: "hex",
|
|
||||||
});
|
|
||||||
|
|
||||||
return `linear-gradient(135deg, ${darkenColor(output as string, 0.5)}, ${darkenColor(output as string, 0.6, 0.5)})`;
|
return `linear-gradient(135deg, ${darkenColor(output as string, 0.5)}, ${darkenColor(output as string, 0.6, 0.5)})`;
|
||||||
};
|
};
|
||||||
@@ -135,28 +132,25 @@ export function UserProfileContextProvider({
|
|||||||
getUserLibraryGames();
|
getUserLibraryGames();
|
||||||
|
|
||||||
return window.electron.hydraApi
|
return window.electron.hydraApi
|
||||||
.get<UserProfile | null>(`/users/${userId}`)
|
.get<UserProfile>(`/users/${userId}`)
|
||||||
.then((userProfile) => {
|
.then((userProfile) => {
|
||||||
if (userProfile) {
|
setUserProfile(userProfile);
|
||||||
setUserProfile(userProfile);
|
|
||||||
|
|
||||||
if (userProfile.profileImageUrl) {
|
if (userProfile.profileImageUrl) {
|
||||||
getHeroBackgroundFromImageUrl(userProfile.profileImageUrl).then(
|
getHeroBackgroundFromImageUrl(userProfile.profileImageUrl).then(
|
||||||
(color) => setHeroBackground(color)
|
(color) => setHeroBackground(color)
|
||||||
);
|
);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
showErrorToast(t("user_not_found"));
|
|
||||||
navigate(-1);
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
showErrorToast(t("user_not_found"));
|
||||||
|
navigate(-1);
|
||||||
});
|
});
|
||||||
}, [navigate, getUserStats, getUserLibraryGames, showErrorToast, userId, t]);
|
}, [navigate, getUserStats, getUserLibraryGames, showErrorToast, userId, t]);
|
||||||
|
|
||||||
const getBadges = useCallback(async () => {
|
const getBadges = useCallback(async () => {
|
||||||
const language = i18n.language.split("-")[0];
|
const language = i18n.language.split("-")[0];
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({ locale: language });
|
||||||
locale: language,
|
|
||||||
});
|
|
||||||
|
|
||||||
const badges = await window.electron.hydraApi.get<Badge[]>(
|
const badges = await window.electron.hydraApi.get<Badge[]>(
|
||||||
`/badges?${params.toString()}`,
|
`/badges?${params.toString()}`,
|
||||||
|
|||||||
@@ -1047,9 +1047,9 @@
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
global-agent "^3.0.0"
|
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"
|
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:
|
dependencies:
|
||||||
env-paths "^2.2.0"
|
env-paths "^2.2.0"
|
||||||
exponential-backoff "^3.1.1"
|
exponential-backoff "^3.1.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user