- app.config.ts: android.versionCode 2 (was 1) - eas.json: development/preview/production profiles, EXPO_PUBLIC_API_URL=staging, appVersionSource=local, autoIncrement=false - avatars: switch DiceBear endpoint /svg -> /png — RN <Image> can't decode SVG, Hero-Avatars rendered transparent/blank on Android Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import { getAvatarById, getAvatarUrl } from './avatars';
|
|
|
|
// PNG, not SVG — RN <Image> can't decode SVG. DiceBear serves PNG at the /png path.
|
|
const DICEBEAR_BASE = 'https://api.dicebear.com/9.x/adventurer/png';
|
|
|
|
/**
|
|
* Resolves the `profiles.avatar` field zu einer renderbaren URL.
|
|
*
|
|
* Drei Quellen-Formate werden unterstützt:
|
|
* 1. Hero-Avatar-ID (z.B. "spider", "hulk") → DiceBear-URL aus HERO_AVATARS
|
|
* 2. Custom-Photo-URL (https://... — User hat Foto via Profile-Edit
|
|
* hochgeladen, gespeichert in Supabase-Storage) → unverändert durchreichen
|
|
* 3. Leer / unbekannt → Dicebear-Initials-Fallback per nickname
|
|
*
|
|
* Wichtig: NICHT blindly getAvatarUrl(avatarId) aufrufen — das gab vorher den
|
|
* Dicebear-anonym-Fallback zurück wenn avatarId zwar truthy aber kein Hero
|
|
* (z.B. Foto-URL). Jetzt wird zuerst auf URL geprüft.
|
|
*/
|
|
export function resolveAvatar(avatarId: string | null | undefined, nickname: string): string {
|
|
if (avatarId) {
|
|
if (/^https?:\/\//i.test(avatarId)) {
|
|
return avatarId;
|
|
}
|
|
if (getAvatarById(avatarId)) {
|
|
return getAvatarUrl(avatarId);
|
|
}
|
|
}
|
|
const seed = encodeURIComponent(nickname || 'anonym');
|
|
return `${DICEBEAR_BASE}?seed=${seed}&backgroundColor=374151`;
|
|
}
|