From eea56a742ef8cec60b048d76776a1f28a9c54acc Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 1 Jan 2026 11:10:04 +0800 Subject: [PATCH] :bug: Fix the paging refreshing issue --- lib/pods/paging.dart | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/pods/paging.dart b/lib/pods/paging.dart index 255a4878..6782cf02 100644 --- a/lib/pods/paging.dart +++ b/lib/pods/paging.dart @@ -8,6 +8,7 @@ abstract class PaginationController { bool get fetchedAll; bool get isLoading; + bool get isReloading; bool get hasMore; set hasMore(bool value); String? get cursor; @@ -32,7 +33,7 @@ mixin AsyncPaginationController on AsyncNotifier> int? totalCount; @override - int get fetchedCount => state.value?.length ?? 0; + int get fetchedCount => isReloading ? 0 : state.value?.length ?? 0; @override bool get fetchedAll => @@ -41,6 +42,9 @@ mixin AsyncPaginationController on AsyncNotifier> @override bool isLoading = false; + @override + bool isReloading = false; + @override bool hasMore = true; @@ -56,6 +60,7 @@ mixin AsyncPaginationController on AsyncNotifier> @override Future refresh() async { isLoading = true; + isReloading = true; totalCount = null; hasMore = true; cursor = null; @@ -64,8 +69,9 @@ mixin AsyncPaginationController on AsyncNotifier> final newState = await AsyncValue.guard>(() async { return await fetch(); }); - state = newState; + isReloading = false; isLoading = false; + state = newState; } @override @@ -81,8 +87,8 @@ mixin AsyncPaginationController on AsyncNotifier> return [...?state.value, ...elements]; }); - state = newState; isLoading = false; + state = newState; } } @@ -92,6 +98,7 @@ mixin AsyncPaginationFilter on AsyncPaginationController Future applyFilter(F filter) async { if (currentFilter == filter) return; // Reset the data + isReloading = true; isLoading = true; totalCount = null; hasMore = true; @@ -102,7 +109,8 @@ mixin AsyncPaginationFilter on AsyncPaginationController final newState = await AsyncValue.guard>(() async { return await fetch(); }); - state = newState; isLoading = false; + isReloading = false; + state = newState; } }