Merge branch 'krille/implement-canrequesthistory' into 'main'

feat: Implement can request history calculation

See merge request famedly/famedlysdk!659
This commit is contained in:
Sorunome 2021-02-26 16:09:17 +00:00
commit 5431056c1c
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));