feat: rooms list with real Matrix data, MXC avatars and unread badges

This commit is contained in:
Bernd Steckmeister
2026-04-19 20:07:20 +02:00
parent 883d24479b
commit 5a909f0e0d
4 changed files with 273 additions and 4 deletions
+25
View File
@@ -0,0 +1,25 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:matrix/matrix.dart';
import 'package:pyramid/core/matrix_client.dart';
final roomListProvider = StreamProvider<List<Room>>((ref) async* {
final client = await ref.watch(matrixClientProvider.future);
yield _sortedRooms(client);
await for (final _ in client.onSync.stream) {
yield _sortedRooms(client);
}
});
List<Room> _sortedRooms(Client client) {
final rooms = client.rooms
.where((r) => !r.isSpace)
.toList()
..sort((a, b) {
final aTime = a.lastEvent?.originServerTs ?? DateTime(0);
final bTime = b.lastEvent?.originServerTs ?? DateTime(0);
return bTime.compareTo(aTime);
});
return rooms;
}