fix(mobile): Chat startet bei neuester Nachricht und Chats nach letzter Aktivität sortieren
Der Verlauf nutzt eine invertierte Liste und öffnet dadurch immer ganz unten. Raumlisten liefern lastActivityAt; die App sortiert alle Chats danach und zieht einen Chat nach dem Senden sofort nach oben. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@ import assert from 'node:assert/strict';
|
||||
import { test } from 'node:test';
|
||||
import {
|
||||
applyChatAccess, chatCursor, chatEndpoint, collaborationKey, createChatApi, matchesChatSearch,
|
||||
mergeChatMessages, validChatImage, visibleChatRooms,
|
||||
mergeChatMessages, sortChatRooms, touchChatRoom, validChatImage, visibleChatRooms,
|
||||
} from '../src/lib/chat.ts';
|
||||
|
||||
const id = '11111111-1111-4111-8111-111111111111';
|
||||
@@ -131,3 +131,22 @@ test('Noch nicht angelegte Direkt- und Projektchats werden gezielt provisioniert
|
||||
assert.equal(calls[1].path, '/api/communication/chat/direct-rooms/user%2Fid/provision');
|
||||
assert.equal(chatEndpoint(remote), `/api/collaboration/rooms/${id}`);
|
||||
});
|
||||
|
||||
test('Chats werden nach letzter Aktivität sortiert, neue Nachrichten rücken nach oben', () => {
|
||||
const rooms = [
|
||||
{ key: 'ohne', name: 'Ohne Aktivität', source: 'internal', exists: false },
|
||||
{ key: 'alt', name: 'Alt', source: 'internal', exists: true, lastActivityAt: '2026-01-01T10:00:00.000Z' },
|
||||
{ key: 'neu', name: 'Neu', source: 'collaboration', exists: true, lastActivityAt: '2026-03-01T10:00:00.000Z' },
|
||||
];
|
||||
assert.deepEqual(sortChatRooms(rooms).map(room => room.key), ['neu', 'alt', 'ohne']);
|
||||
assert.deepEqual(touchChatRoom(rooms, 'alt', '2026-04-01T10:00:00.000Z').map(room => room.key), ['alt', 'neu', 'ohne']);
|
||||
assert.equal(rooms[1].lastActivityAt, '2026-01-01T10:00:00.000Z');
|
||||
});
|
||||
test('Verzeichnis sortiert Räume aller Gruppen gemeinsam nach Aktivität', async () => {
|
||||
const { api } = fixture({
|
||||
'/api/communication/chat/rooms': { rooms: [{ ...internal, lastActivityAt: '2026-01-01T00:00:00.000Z' }] },
|
||||
'/api/collaboration': { rooms: [{ id, name: 'Partner', lastActivityAt: '2026-02-01T00:00:00.000Z' }], invitations: [] },
|
||||
});
|
||||
const result = await api.directory('token');
|
||||
assert.deepEqual(result.rooms.map(room => room.key), [collaborationKey(id), 'allgemein', 'project_42']);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user