fix: solve small pm chat ui issues

unwrap the pill
fix the fetching images in pm not auto download
This commit is contained in:
2026-05-25 17:17:32 +02:00
parent 1259645706
commit 161f57f52e
28 changed files with 697 additions and 82 deletions

View File

@@ -20,7 +20,8 @@ function createMessage(overrides: Partial<Message> = {}): Message {
function createContext(overrides: Record<string, unknown> = {}) {
return {
db: {
getMessages: vi.fn()
getMessages: vi.fn(),
getRoomMessageStats: vi.fn(async () => ({ count: 0, lastUpdated: 0 }))
},
webrtc: {
sendToPeer: vi.fn()
@@ -36,12 +37,12 @@ function createContext(overrides: Record<string, unknown> = {}) {
describe('dispatchIncomingMessage room-scoped sync', () => {
it('requests sync for event room even when another room is viewed', async () => {
const getMessages = vi.fn(async (roomId: string) => roomId === 'room-b'
? [createMessage({ roomId: 'room-b', timestamp: 10, editedAt: 10 })]
: [createMessage({ roomId: 'room-a', timestamp: 100, editedAt: 100 })]);
const getRoomMessageStats = vi.fn(async (roomId: string) => roomId === 'room-b'
? { count: 1, lastUpdated: 10 }
: { count: 1, lastUpdated: 100 });
const sendToPeer = vi.fn();
const context = createContext({
db: { getMessages },
db: { getMessages: vi.fn(), getRoomMessageStats },
webrtc: { sendToPeer },
currentRoom: { id: 'room-a' },
savedRooms: [{ id: 'room-b' }]
@@ -60,7 +61,7 @@ describe('dispatchIncomingMessage room-scoped sync', () => {
).pipe(defaultIfEmpty(null))
);
expect(getMessages).toHaveBeenCalledWith('room-b', expect.any(Number), 0);
expect(getRoomMessageStats).toHaveBeenCalledWith('room-b');
expect(sendToPeer).toHaveBeenCalledWith('peer-1', {
type: 'chat-sync-request',
roomId: 'room-b'