export interface FriendAvatarSource { user_id: string; topic?: string; avatar_file_id?: string; } /** * P2P contacts are keyed by their `p2p...` topic after the first subscription, * while the friends API identifies the same person with a `usr...` user ID. * Keep both aliases so avatars work during both the initial and established * conversation states. */ export function friendAvatarLookup(friends: FriendAvatarSource[] = []) { const avatars = new Map(); for (const friend of friends) { if (friend.user_id) avatars.set(friend.user_id, friend.avatar_file_id); if (friend.topic) avatars.set(friend.topic, friend.avatar_file_id); } return avatars; }