Files
cinny/src/app/components/authenticated-media/AuthenticatedAvatarImage.tsx
T
litruv a6ad8651b3
Checks / checks (push) Successful in 2m11s
Trigger cinny-mobile / dispatch (push) Successful in 1s
Apply the auto-fixable lint rules and the formatter, and drop the Vite build artifacts.
2026-11-01 04:23:53 +11:00

23 lines
948 B
TypeScript

import React, { ComponentProps, forwardRef } from 'react';
import { AvatarImage } from 'folds';
import { useAuthenticatedMediaUrl } from '../../hooks/useAuthenticatedMediaUrl';
import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
export type AuthenticatedAvatarImageProps = ComponentProps<typeof AvatarImage>;
/**
* AvatarImage component that handles Matrix authenticated media.
* Automatically fetches authenticated media URLs with the proper Authorization header
* and renders them as blob URLs.
*/
export const AuthenticatedAvatarImage = forwardRef<HTMLImageElement, AuthenticatedAvatarImageProps>(
({ src, ...props }, ref) => {
const useAuthentication = useMediaAuthentication();
const authenticatedSrc = useAuthenticatedMediaUrl(src, useAuthentication);
return <AvatarImage ref={ref} {...props} src={authenticatedSrc} />;
},
);
AuthenticatedAvatarImage.displayName = 'AuthenticatedAvatarImage';