fix p2p conversation avatars

This commit is contained in:
richjohnrambo
2026-10-14 16:09:38 +08:00
parent 8a26a4ccf9
commit 361e23b9ec
3 changed files with 47 additions and 2 deletions
+24
View File
@@ -0,0 +1,24 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { friendAvatarLookup } from '../src/features/messages/chat-list.ts';
test('friend avatars resolve by both user ID and established P2P topic', () => {
const avatars = friendAvatarLookup([
{
user_id: 'usr-potter',
topic: 'p2p-potter',
avatar_file_id: 'https://example.com/potter.png',
},
]);
assert.equal(avatars.get('usr-potter'), 'https://example.com/potter.png');
assert.equal(avatars.get('p2p-potter'), 'https://example.com/potter.png');
});
test('friend avatar lookup tolerates a new conversation without a topic alias', () => {
const avatars = friendAvatarLookup([{ user_id: 'usr-new', avatar_file_id: 'avatar-file-id' }]);
assert.equal(avatars.get('usr-new'), 'avatar-file-id');
assert.equal(avatars.has(''), false);
});