Download Avatar from relevent source

Instead of relying on failures directly use the
available method to download the avatar.
This commit is contained in:
JephDiel
2026-03-09 22:25:54 -05:00
parent 005b965fba
commit 699e31f59a
4 changed files with 47 additions and 76 deletions

View File

@@ -48,7 +48,7 @@ export type ValidClientState = {
disconnected: boolean;
supportedFeatures: {
reactions: boolean;
thumbnails: boolean;
authenticatedMedia: boolean;
};
setClient: (client: MatrixClient, session: Session) => void;
};
@@ -249,7 +249,8 @@ export const ClientProvider: FC<Props> = ({ children }) => {
const [isDisconnected, setIsDisconnected] = useState(false);
const [supportsReactions, setSupportsReactions] = useState(false);
const [supportsThumbnails, setSupportsThumbnails] = useState(false);
const [supportsAuthenticatedMedia, setSupportsAuthenticatedMedia] =
useState(false);
const state: ClientState | undefined = useMemo(() => {
if (alreadyOpenedErr) {
@@ -275,7 +276,7 @@ export const ClientProvider: FC<Props> = ({ children }) => {
disconnected: isDisconnected,
supportedFeatures: {
reactions: supportsReactions,
thumbnails: supportsThumbnails,
authenticatedMedia: supportsAuthenticatedMedia,
},
};
}, [
@@ -286,7 +287,7 @@ export const ClientProvider: FC<Props> = ({ children }) => {
setClient,
isDisconnected,
supportsReactions,
supportsThumbnails,
supportsAuthenticatedMedia,
]);
const onSync = useCallback(
@@ -312,8 +313,8 @@ export const ClientProvider: FC<Props> = ({ children }) => {
}
if (initClientState.widgetApi) {
// There is currently no widget API for authenticated media thumbnails.
setSupportsThumbnails(false);
// There is currently no way for widgets to request authenticated media directly from the server.
setSupportsAuthenticatedMedia(false);
const reactSend = initClientState.widgetApi.hasCapability(
"org.matrix.msc2762.send.event:m.reaction",
);
@@ -335,7 +336,7 @@ export const ClientProvider: FC<Props> = ({ children }) => {
}
} else {
setSupportsReactions(true);
setSupportsThumbnails(true);
setSupportsAuthenticatedMedia(true);
}
return (): void => {