fix p2p conversation avatars
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
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<string, string | undefined>();
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user