From d2806fdc3a833b9da1f5c903c69e07b8d4bc48a7 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 7 Jan 2026 19:44:53 +0800 Subject: [PATCH] :lipstick: Optimize timeline cursor picking --- lib/pods/timeline.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pods/timeline.dart b/lib/pods/timeline.dart index d4a4b683..b91faddc 100644 --- a/lib/pods/timeline.dart +++ b/lib/pods/timeline.dart @@ -58,17 +58,17 @@ class ActivityListNotifier // Find the latest createdAt timestamp from all items for cursor-based pagination // This ensures we get items created before this timestamp, regardless of sort order if (items.isNotEmpty) { - final latestCreatedAt = items + final newestCreatedAt = items .where((e) => e.type.startsWith('posts.')) .map((e) => e.createdAt) .reduce((a, b) => a.isBefore(b) ? a : b); if (cursor != null) { final prevCursor = DateTime.tryParse(cursor!); - if (prevCursor != null && prevCursor.isAfter(latestCreatedAt)) { - cursor = latestCreatedAt.toUtc().toIso8601String(); + if (prevCursor != null && prevCursor.isAfter(newestCreatedAt)) { + cursor = newestCreatedAt.toUtc().toIso8601String(); } } else { - cursor = latestCreatedAt.toUtc().toIso8601String(); + cursor = newestCreatedAt.toUtc().toIso8601String(); } }