Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(frontend): photo de profil sur Firefox #13

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions frontend/src/context/api/ApiProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ const ApiContext = React.createContext<ApiContextType>(null!);
* @returns {ReactElement} The rendered child components wrapped in the ApiProvider.Provider.
*/
export function ApiProvider({
baseUrl,
auth,
client,
children,
}: {
baseUrl,
auth,
client,
children,
}: {
baseUrl: string;
auth?: AuthContextType;
client: QueryClient;
Expand Down
32 changes: 18 additions & 14 deletions frontend/src/controls/Avatars/UtilisateurAvatarImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,15 @@ export default function UtilisateurAvatarImage(props: {
}

return fetch(`${env.REACT_APP_API}${utilisateurData?.["@id"]}/photo`, fetchOptions)
.then((response) => response.blob())
.then((response) => {
if (response.status === 200) {
return response.blob();
}
return null;
})
.then((blob) => {
if (blob.type !== "application/ld+json") {
if (blob) {
// image renvoyée
return window.URL.createObjectURL(blob);
} else {
return null;
Expand Down Expand Up @@ -145,18 +151,16 @@ export default function UtilisateurAvatarImage(props: {
if (props.as === "img") {
if (photo.data)
return (
<>
<Image
alt={`Photo de ${utilisateurData.prenom} ${utilisateurData.nom}`}
aria-hidden
width={props.width}
height={props.height}
src={photo.data ?? ""}
style={{ objectFit: "contain" }}
className="border-radius"
rootClassName={`${props.className} border-radius`}
/>
</>
<Image
alt={`Photo de ${utilisateurData.prenom} ${utilisateurData.nom}`}
aria-hidden
width={props.width}
height={props.height}
src={photo.data ?? ""}
style={{ objectFit: "contain" }}
className="border-radius"
rootClassName={`${props.className} border-radius`}
/>
);
}

Expand Down