23 lines
746 B
Dart
23 lines
746 B
Dart
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:matrix/matrix.dart';
|
|
import 'package:pyramid/core/matrix_client.dart';
|
|
|
|
final timelineProvider =
|
|
FutureProvider.family<Timeline, String>((ref, roomId) async {
|
|
final client = await ref.watch(matrixClientProvider.future);
|
|
final room = client.getRoomById(roomId);
|
|
if (room == null) throw Exception('Raum nicht gefunden: $roomId');
|
|
|
|
final timeline = await room.getTimeline(
|
|
onUpdate: () => ref.invalidateSelf(),
|
|
);
|
|
|
|
ref.onDispose(timeline.cancelSubscriptions);
|
|
return timeline;
|
|
});
|
|
|
|
final roomProvider = Provider.family<Room?, String>((ref, roomId) {
|
|
final client = ref.watch(matrixClientProvider).valueOrNull;
|
|
return client?.getRoomById(roomId);
|
|
});
|