From d7858bab6782b8abecfe4485621c1b6f0f658811 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Fri, 2 Jan 2026 02:34:45 +0800 Subject: [PATCH] :bug: Fix some bugs --- lib/pods/paging.dart | 15 ++++++++++----- lib/screens/explore.dart | 33 ++++++++++++++++++++++++++------- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/lib/pods/paging.dart b/lib/pods/paging.dart index 024c7e27..fa1be7b2 100644 --- a/lib/pods/paging.dart +++ b/lib/pods/paging.dart @@ -120,7 +120,8 @@ mixin AsyncPaginationController on AsyncNotifier> @override Future refresh() async { state = AsyncData( - state.value!.copyWith( + PaginationState( + items: [], isLoading: true, isReloading: true, totalCount: null, @@ -131,8 +132,9 @@ mixin AsyncPaginationController on AsyncNotifier> final newItems = await fetch(); + if (!ref.mounted) return; state = AsyncData( - state.value!.copyWith( + PaginationState( items: newItems, isLoading: false, isReloading: false, @@ -152,6 +154,7 @@ mixin AsyncPaginationController on AsyncNotifier> final newItems = await fetch(); + if (!ref.mounted) return; state = AsyncData( state.value!.copyWith( items: [...state.value!.items, ...newItems], @@ -168,9 +171,10 @@ mixin AsyncPaginationFilter on AsyncPaginationController if (currentFilter == filter) return; state = AsyncData( - state.value!.copyWith( - isReloading: true, + PaginationState( + items: [], isLoading: true, + isReloading: true, totalCount: null, hasMore: true, cursor: null, @@ -180,8 +184,9 @@ mixin AsyncPaginationFilter on AsyncPaginationController final newItems = await fetch(); + if (!ref.mounted) return; state = AsyncData( - state.value!.copyWith( + PaginationState( items: newItems, isLoading: false, isReloading: false, diff --git a/lib/screens/explore.dart b/lib/screens/explore.dart index e202dfbd..6d5c4514 100644 --- a/lib/screens/explore.dart +++ b/lib/screens/explore.dart @@ -391,6 +391,8 @@ class ExploreScreen extends HookConsumerWidget { ? null // Post list handles its own refreshing : ref.watch(activityListProvider.notifier); + final activityState = ref.watch(activityListProvider); + return Row( spacing: 12, children: [ @@ -403,6 +405,10 @@ class ExploreScreen extends HookConsumerWidget { child: CustomScrollView( slivers: [ const SliverGap(12), + if (activityState.value?.isLoading ?? false) + SliverToBoxAdapter( + child: LinearProgressIndicator().padding(bottom: 8), + ), SliverToBoxAdapter(child: filterBar), const SliverGap(8), bodyView, @@ -604,14 +610,27 @@ class ExploreScreen extends HookConsumerWidget { final notifier = ref.watch(activityListProvider.notifier); + final activityState = ref.watch(activityListProvider); + return Expanded( - child: ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(8)), - child: ExtendedRefreshIndicator( - onRefresh: notifier.refresh, - child: CustomScrollView(slivers: [SliverGap(8), bodyView]), - ), - ).padding(horizontal: 8), + child: Stack( + children: [ + ClipRRect( + borderRadius: const BorderRadius.all(Radius.circular(8)), + child: ExtendedRefreshIndicator( + onRefresh: notifier.refresh, + child: CustomScrollView(slivers: [SliverGap(8), bodyView]), + ), + ).padding(horizontal: 8), + if (activityState.isLoading) + Positioned.fill( + child: Container( + color: Colors.grey.withOpacity(0.3), + child: const Center(child: CircularProgressIndicator()), + ), + ), + ], + ), ); } }