feat: Implement can request history calculation
This commit is contained in:
parent
62ad8569ae
commit
b8659213ae
|
|
@ -68,6 +68,11 @@ class Timeline {
|
||||||
bool _collectHistoryUpdates = false;
|
bool _collectHistoryUpdates = false;
|
||||||
final Set<EventUpdate> _historyUpdates = <EventUpdate>{};
|
final Set<EventUpdate> _historyUpdates = <EventUpdate>{};
|
||||||
|
|
||||||
|
bool get canRequestHistory {
|
||||||
|
if (events.isEmpty) return true;
|
||||||
|
return events.last.type != EventTypes.RoomCreate;
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> requestHistory(
|
Future<void> requestHistory(
|
||||||
{int historyCount = Room.DefaultHistoryCount}) async {
|
{int historyCount = Room.DefaultHistoryCount}) async {
|
||||||
if (!isRequestingHistory) {
|
if (!isRequestingHistory) {
|
||||||
|
|
|
||||||
|
|
@ -283,6 +283,7 @@ void main() {
|
||||||
|
|
||||||
test('Request history', () async {
|
test('Request history', () async {
|
||||||
timeline.events.clear();
|
timeline.events.clear();
|
||||||
|
expect(timeline.canRequestHistory, true);
|
||||||
await room.requestHistory();
|
await room.requestHistory();
|
||||||
|
|
||||||
await Future.delayed(Duration(milliseconds: 50));
|
await Future.delayed(Duration(milliseconds: 50));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue