fix(native/community): ComposeCard avatar reads from useMe, not auth metadata

The composer on the index page was rendering whatever avatar was set
in `auth.users.user_metadata.avatar_id` at signup time — never updated
when the user changes their avatar via Profile-Edit (those edits go to
`profiles` table only, JWT claims stay stale).

useMe() is the single source of truth that joins both server-side (see
hooks/useMe.ts:15-18 comment that explicitly lists ComposeCard as a
consumer that should subscribe). Switched the avatar + nickname reads
to useMe(); future PATCH /api/auth/me followed by invalidateMe() now
updates the composer avatar in real time alongside the AppHeader.
This commit is contained in:
chahinebrini 2026-05-15 23:55:57 +02:00
parent 917361131d
commit 5d74214822

View File

@ -17,7 +17,7 @@ import * as FileSystem from 'expo-file-system/legacy';
import * as ImagePicker from 'expo-image-picker';
import { apiFetch } from '../lib/api';
import { resolveAvatar } from '../lib/resolveAvatar';
import { useAuthStore } from '../stores/auth';
import { useMe } from '../hooks/useMe';
import { useColors } from '../lib/theme';
type Props = {
@ -27,7 +27,7 @@ type Props = {
export function ComposeCard({ onPosted }: Props) {
const { t } = useTranslation();
const colors = useColors();
const { user } = useAuthStore();
const { me } = useMe();
const queryClient = useQueryClient();
const inputRef = useRef<TextInput>(null);
const [focused, setFocused] = useState(false);
@ -35,9 +35,8 @@ export function ComposeCard({ onPosted }: Props) {
const [imageUri, setImageUri] = useState<string | null>(null);
const [posting, setPosting] = useState(false);
const avatarId = user?.user_metadata?.avatar_id as string | undefined;
const nickname = (user?.user_metadata?.username as string | undefined) ?? t('community.compose_default_user');
const avatarUrl = resolveAvatar(avatarId ?? null, nickname);
const nickname = me?.nickname ?? t('community.compose_default_user');
const avatarUrl = resolveAvatar(me?.avatar ?? null, nickname);
const cancel = () => {
setContent('');