Improve loading of chat events

This commit is contained in:
2024-09-15 10:55:27 +08:00
parent 00449f3f83
commit 2183a2ca55
5 changed files with 29 additions and 49 deletions

View File

@ -51,12 +51,12 @@ class MessagesFetchingProvider extends GetxController {
Future<(List<Event>, int)?> fetchRemoteEvents(
Channel channel,
String scope, {
required int remainDepth,
required int depth,
bool Function(List<Event> items)? onBrake,
take = 10,
offset = 0,
}) async {
if (remainDepth <= 0) {
if (depth <= 0) {
return null;
}
@ -84,7 +84,7 @@ class MessagesFetchingProvider extends GetxController {
final expandResult = (await fetchRemoteEvents(
channel,
scope,
remainDepth: remainDepth - 1,
depth: depth - 1,
take: take,
offset: offset + result.length,
))
@ -162,7 +162,7 @@ class MessagesFetchingProvider extends GetxController {
final data = await fetchRemoteEvents(
channel,
scope,
remainDepth: depth,
depth: depth,
offset: offset,
onBrake: (items) {
return items.any((x) => x.id == lastOne?.id);