♻️ Rebuilt fetching state machine
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
@@ -28,10 +30,23 @@ final socialCreditHistoryNotifierProvider = AsyncNotifierProvider.autoDispose(
|
||||
);
|
||||
|
||||
class SocialCreditHistoryNotifier
|
||||
extends AsyncNotifier<List<SnSocialCreditRecord>>
|
||||
extends AsyncNotifier<PaginationState<SnSocialCreditRecord>>
|
||||
with AsyncPaginationController<SnSocialCreditRecord> {
|
||||
static const int pageSize = 20;
|
||||
|
||||
@override
|
||||
FutureOr<PaginationState<SnSocialCreditRecord>> build() async {
|
||||
final items = await fetch();
|
||||
return PaginationState(
|
||||
items: items,
|
||||
isLoading: false,
|
||||
isReloading: false,
|
||||
totalCount: totalCount,
|
||||
hasMore: hasMore,
|
||||
cursor: cursor,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<SnSocialCreditRecord>> fetch() async {
|
||||
final client = ref.read(apiClientProvider);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
@@ -14,14 +16,30 @@ import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:island/widgets/paging/pagination_list.dart';
|
||||
import 'package:styled_widget/styled_widget.dart';
|
||||
|
||||
final levelingHistoryNotifierProvider = AsyncNotifierProvider.autoDispose(
|
||||
LevelingHistoryNotifier.new,
|
||||
);
|
||||
final levelingHistoryNotifierProvider =
|
||||
AsyncNotifierProvider.autoDispose<
|
||||
LevelingHistoryNotifier,
|
||||
PaginationState<SnExperienceRecord>
|
||||
>(LevelingHistoryNotifier.new);
|
||||
|
||||
class LevelingHistoryNotifier extends AsyncNotifier<List<SnExperienceRecord>>
|
||||
class LevelingHistoryNotifier
|
||||
extends AsyncNotifier<PaginationState<SnExperienceRecord>>
|
||||
with AsyncPaginationController<SnExperienceRecord> {
|
||||
static const int pageSize = 20;
|
||||
|
||||
@override
|
||||
FutureOr<PaginationState<SnExperienceRecord>> build() async {
|
||||
final items = await fetch();
|
||||
return PaginationState(
|
||||
items: items,
|
||||
isLoading: false,
|
||||
isReloading: false,
|
||||
totalCount: totalCount,
|
||||
hasMore: hasMore,
|
||||
cursor: cursor,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<SnExperienceRecord>> fetch() async {
|
||||
final client = ref.read(apiClientProvider);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -29,12 +31,28 @@ Future<List<SnRelationship>> sentFriendRequest(Ref ref) async {
|
||||
.toList();
|
||||
}
|
||||
|
||||
final relationshipListNotifierProvider = AsyncNotifierProvider.autoDispose(
|
||||
RelationshipListNotifier.new,
|
||||
);
|
||||
final relationshipListNotifierProvider =
|
||||
AsyncNotifierProvider.autoDispose<
|
||||
RelationshipListNotifier,
|
||||
PaginationState<SnRelationship>
|
||||
>(RelationshipListNotifier.new);
|
||||
|
||||
class RelationshipListNotifier extends AsyncNotifier<List<SnRelationship>>
|
||||
class RelationshipListNotifier
|
||||
extends AsyncNotifier<PaginationState<SnRelationship>>
|
||||
with AsyncPaginationController<SnRelationship> {
|
||||
@override
|
||||
FutureOr<PaginationState<SnRelationship>> build() async {
|
||||
final items = await fetch();
|
||||
return PaginationState(
|
||||
items: items,
|
||||
isLoading: false,
|
||||
isReloading: false,
|
||||
totalCount: totalCount,
|
||||
hasMore: hasMore,
|
||||
cursor: cursor,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<SnRelationship>> fetch() async {
|
||||
final client = ref.read(apiClientProvider);
|
||||
|
||||
@@ -588,7 +588,8 @@ final chatMemberListProvider = AsyncNotifierProvider.autoDispose.family(
|
||||
ChatMemberListNotifier.new,
|
||||
);
|
||||
|
||||
class ChatMemberListNotifier extends AsyncNotifier<List<SnChatMember>>
|
||||
class ChatMemberListNotifier
|
||||
extends AsyncNotifier<PaginationState<SnChatMember>>
|
||||
with AsyncPaginationController<SnChatMember> {
|
||||
static const pageSize = 20;
|
||||
|
||||
|
||||
@@ -96,13 +96,27 @@ Future<SnActorStatusResponse> publisherActorStatus(
|
||||
final publisherMemberListNotifierProvider = AsyncNotifierProvider.family
|
||||
.autoDispose(PublisherMemberListNotifier.new);
|
||||
|
||||
class PublisherMemberListNotifier extends AsyncNotifier<List<SnPublisherMember>>
|
||||
class PublisherMemberListNotifier
|
||||
extends AsyncNotifier<PaginationState<SnPublisherMember>>
|
||||
with AsyncPaginationController<SnPublisherMember> {
|
||||
static const int pageSize = 20;
|
||||
|
||||
final String arg;
|
||||
PublisherMemberListNotifier(this.arg);
|
||||
|
||||
@override
|
||||
FutureOr<PaginationState<SnPublisherMember>> build() async {
|
||||
final items = await fetch();
|
||||
return PaginationState(
|
||||
items: items,
|
||||
isLoading: false,
|
||||
isReloading: false,
|
||||
totalCount: totalCount,
|
||||
hasMore: hasMore,
|
||||
cursor: cursor,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<SnPublisherMember>> fetch() async {
|
||||
final apiClient = ref.read(apiClientProvider);
|
||||
|
||||
@@ -21,7 +21,7 @@ final pollListNotifierProvider = AsyncNotifierProvider.family.autoDispose(
|
||||
PollListNotifier.new,
|
||||
);
|
||||
|
||||
class PollListNotifier extends AsyncNotifier<List<SnPollWithStats>>
|
||||
class PollListNotifier extends AsyncNotifier<PaginationState<SnPollWithStats>>
|
||||
with AsyncPaginationController<SnPollWithStats> {
|
||||
static const int pageSize = 20;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ final siteListNotifierProvider = AsyncNotifierProvider.family.autoDispose(
|
||||
SiteListNotifier.new,
|
||||
);
|
||||
|
||||
class SiteListNotifier extends AsyncNotifier<List<SnPublicationSite>>
|
||||
class SiteListNotifier extends AsyncNotifier<PaginationState<SnPublicationSite>>
|
||||
with AsyncPaginationController<SnPublicationSite> {
|
||||
static const int pageSize = 20;
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ final stickerPacksProvider = AsyncNotifierProvider.family.autoDispose(
|
||||
StickerPacksNotifier.new,
|
||||
);
|
||||
|
||||
class StickerPacksNotifier extends AsyncNotifier<List<SnStickerPack>>
|
||||
class StickerPacksNotifier extends AsyncNotifier<PaginationState<SnStickerPack>>
|
||||
with AsyncPaginationController<SnStickerPack> {
|
||||
static const int pageSize = 20;
|
||||
|
||||
|
||||
@@ -412,11 +412,11 @@ class NotificationsCard extends HookConsumerWidget {
|
||||
loading: () => const SkeletonNotificationTile(),
|
||||
error: (error, stack) => Center(child: Text('Error: $error')),
|
||||
data: (notificationList) {
|
||||
if (notificationList.isEmpty) {
|
||||
if (notificationList.items.isEmpty) {
|
||||
return Center(child: Text('noNotificationsYet').tr());
|
||||
}
|
||||
// Get the most recent notification (first in the list)
|
||||
final recentNotification = notificationList.first;
|
||||
final recentNotification = notificationList.items.first;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
||||
@@ -22,7 +22,7 @@ final articlesListNotifierProvider = AsyncNotifierProvider.family.autoDispose(
|
||||
ArticlesListNotifier.new,
|
||||
);
|
||||
|
||||
class ArticlesListNotifier extends AsyncNotifier<List<SnWebArticle>>
|
||||
class ArticlesListNotifier extends AsyncNotifier<PaginationState<SnWebArticle>>
|
||||
with AsyncPaginationController<SnWebArticle> {
|
||||
static const int pageSize = 20;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ final marketplaceWebFeedContentNotifierProvider = AsyncNotifierProvider.family
|
||||
.autoDispose(MarketplaceWebFeedContentNotifier.new);
|
||||
|
||||
class MarketplaceWebFeedContentNotifier
|
||||
extends AsyncNotifier<List<SnWebArticle>>
|
||||
extends AsyncNotifier<PaginationState<SnWebArticle>>
|
||||
with AsyncPaginationController<SnWebArticle> {
|
||||
static const int pageSize = 20;
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ final marketplaceWebFeedsNotifierProvider = AsyncNotifierProvider.autoDispose(
|
||||
MarketplaceWebFeedsNotifier.new,
|
||||
);
|
||||
|
||||
class MarketplaceWebFeedsNotifier extends AsyncNotifier<List<SnWebFeed>>
|
||||
class MarketplaceWebFeedsNotifier
|
||||
extends AsyncNotifier<PaginationState<SnWebFeed>>
|
||||
with
|
||||
AsyncPaginationController<SnWebFeed>,
|
||||
AsyncPaginationFilter<String?, SnWebFeed> {
|
||||
|
||||
@@ -164,10 +164,24 @@ final notificationListProvider = AsyncNotifierProvider.autoDispose(
|
||||
NotificationListNotifier.new,
|
||||
);
|
||||
|
||||
class NotificationListNotifier extends AsyncNotifier<List<SnNotification>>
|
||||
class NotificationListNotifier
|
||||
extends AsyncNotifier<PaginationState<SnNotification>>
|
||||
with AsyncPaginationController<SnNotification> {
|
||||
static const int pageSize = 5;
|
||||
|
||||
@override
|
||||
FutureOr<PaginationState<SnNotification>> build() async {
|
||||
final items = await fetch();
|
||||
return PaginationState(
|
||||
items: items,
|
||||
isLoading: false,
|
||||
isReloading: false,
|
||||
totalCount: totalCount,
|
||||
hasMore: hasMore,
|
||||
cursor: cursor,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<SnNotification>> fetch() async {
|
||||
final client = ref.read(apiClientProvider);
|
||||
|
||||
@@ -160,7 +160,7 @@ class PostSearchScreen extends HookConsumerWidget {
|
||||
);
|
||||
},
|
||||
),
|
||||
if (searchState.value?.isEmpty == true &&
|
||||
if (searchState.value?.items.isEmpty == true &&
|
||||
searchController.text.isNotEmpty &&
|
||||
!searchState.isLoading)
|
||||
SliverFillRemaining(
|
||||
@@ -290,7 +290,7 @@ class PostSearchScreen extends HookConsumerWidget {
|
||||
);
|
||||
},
|
||||
),
|
||||
if (searchState.value?.isEmpty == true &&
|
||||
if (searchState.value?.items.isEmpty == true &&
|
||||
searchController.text.isNotEmpty &&
|
||||
!searchState.isLoading)
|
||||
SliverFillRemaining(
|
||||
|
||||
@@ -492,11 +492,10 @@ class _RealmActionMenu extends HookConsumerWidget {
|
||||
}
|
||||
|
||||
final realmMemberListNotifierProvider = AsyncNotifierProvider.autoDispose
|
||||
.family<RealmMemberListNotifier, List<SnRealmMember>, String>(
|
||||
RealmMemberListNotifier.new,
|
||||
);
|
||||
.family(RealmMemberListNotifier.new);
|
||||
|
||||
class RealmMemberListNotifier extends AsyncNotifier<List<SnRealmMember>>
|
||||
class RealmMemberListNotifier
|
||||
extends AsyncNotifier<PaginationState<SnRealmMember>>
|
||||
with AsyncPaginationController<SnRealmMember> {
|
||||
String arg;
|
||||
RealmMemberListNotifier(this.arg);
|
||||
|
||||
@@ -31,7 +31,8 @@ sealed class MarketplaceStickerQuery with _$MarketplaceStickerQuery {
|
||||
final marketplaceStickerPacksNotifierProvider =
|
||||
AsyncNotifierProvider.autoDispose(MarketplaceStickerPacksNotifier.new);
|
||||
|
||||
class MarketplaceStickerPacksNotifier extends AsyncNotifier<List<SnStickerPack>>
|
||||
class MarketplaceStickerPacksNotifier
|
||||
extends AsyncNotifier<PaginationState<SnStickerPack>>
|
||||
with
|
||||
AsyncPaginationController<SnStickerPack>,
|
||||
AsyncPaginationFilter<MarketplaceStickerQuery, SnStickerPack> {
|
||||
|
||||
@@ -963,7 +963,8 @@ final transactionListProvider = AsyncNotifierProvider.autoDispose(
|
||||
TransactionListNotifier.new,
|
||||
);
|
||||
|
||||
class TransactionListNotifier extends AsyncNotifier<List<SnTransaction>>
|
||||
class TransactionListNotifier
|
||||
extends AsyncNotifier<PaginationState<SnTransaction>>
|
||||
with AsyncPaginationController<SnTransaction> {
|
||||
static const int pageSize = 20;
|
||||
|
||||
@@ -992,7 +993,7 @@ final walletFundsProvider = AsyncNotifierProvider.autoDispose(
|
||||
WalletFundsNotifier.new,
|
||||
);
|
||||
|
||||
class WalletFundsNotifier extends AsyncNotifier<List<SnWalletFund>>
|
||||
class WalletFundsNotifier extends AsyncNotifier<PaginationState<SnWalletFund>>
|
||||
with AsyncPaginationController<SnWalletFund> {
|
||||
static const int pageSize = 20;
|
||||
|
||||
@@ -1020,7 +1021,7 @@ final walletFundRecipientsProvider = AsyncNotifierProvider.autoDispose(
|
||||
);
|
||||
|
||||
class WalletFundRecipientsNotifier
|
||||
extends AsyncNotifier<List<SnWalletFundRecipient>>
|
||||
extends AsyncNotifier<PaginationState<SnWalletFundRecipient>>
|
||||
with AsyncPaginationController<SnWalletFundRecipient> {
|
||||
static const int _pageSize = 20;
|
||||
|
||||
@@ -1484,7 +1485,7 @@ class WalletScreen extends HookConsumerWidget {
|
||||
|
||||
return funds.when(
|
||||
data: (fundList) {
|
||||
if (fundList.isEmpty) {
|
||||
if (fundList.items.isEmpty) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@@ -1514,9 +1515,9 @@ class WalletScreen extends HookConsumerWidget {
|
||||
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: fundList.length,
|
||||
itemCount: fundList.items.length,
|
||||
itemBuilder: (context, index) {
|
||||
final fund = fundList[index];
|
||||
final fund = fundList.items[index];
|
||||
final claimedCount = fund.recipients
|
||||
.where((r) => r.isReceived)
|
||||
.length;
|
||||
|
||||
Reference in New Issue
Block a user