feat: Implement can request history calculation

This commit is contained in:
Christian Pauly 2021-02-25 14:45:31 +01:00
parent 62ad8569ae
commit b8659213ae
2 changed files with 6 additions and 0 deletions

View File

@ -68,6 +68,11 @@ class Timeline {
bool _collectHistoryUpdates = false;
final Set<EventUpdate> _historyUpdates = <EventUpdate>{};
bool get canRequestHistory {
if (events.isEmpty) return true;
return events.last.type != EventTypes.RoomCreate;
}
Future<void> requestHistory(
{int historyCount = Room.DefaultHistoryCount}) async {
if (!isRequestingHistory) {

View File

@ -283,6 +283,7 @@ void main() {
test('Request history', () async {
timeline.events.clear();
expect(timeline.canRequestHistory, true);
await room.requestHistory();
await Future.delayed(Duration(milliseconds: 50));