Simplify widget detection

Use the exists check for the widget API directly
instead of a feature flag.
This commit is contained in:
JephDiel
2026-03-12 22:18:38 -05:00
parent 699e31f59a
commit 8ecb1b3dbf
4 changed files with 16 additions and 30 deletions

View File

@@ -87,23 +87,23 @@ export const Avatar: FC<Props> = ({
const [avatarUrl, setAvatarUrl] = useState<string | undefined>(undefined);
// In theory, a change in `clientState` or `sizePx` could run extra getAvatarFromWidgetAPI calls, but in practice they should be stable long before this code runs.
useEffect(() => {
if (!src || clientState?.state !== "valid") {
if (!src) {
setAvatarUrl(undefined);
return;
}
const { authenticated, supportedFeatures } = clientState;
let blob: Promise<Blob>;
if (
supportedFeatures.authenticatedMedia &&
authenticated?.client &&
if (widget?.api) {
blob = getAvatarFromWidgetAPI(widget.api, src);
} else if (
clientState?.state === "valid" &&
clientState.authenticated?.client &&
sizePx
) {
blob = getAvatarFromServer(authenticated.client, src, sizePx);
} else if (widget?.api) {
blob = getAvatarFromWidgetAPI(widget.api, src);
blob = getAvatarFromServer(clientState.authenticated.client, src, sizePx);
} else {
setAvatarUrl(undefined);
return;