♻️ Migrated to riverpod v3
This commit is contained in:
@@ -60,7 +60,7 @@ class PostComposeCard extends HookConsumerWidget {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
// Capture the notifier to avoid using ref after dispose
|
||||
final notifier = ref.read(composeStorageNotifierProvider.notifier);
|
||||
final notifier = ref.read(composeStorageProvider.notifier);
|
||||
|
||||
// Create compose state
|
||||
final ComposeState composeState =
|
||||
@@ -158,7 +158,7 @@ class PostComposeCard extends HookConsumerWidget {
|
||||
|
||||
// Delete draft after successful submission
|
||||
ref
|
||||
.read(composeStorageNotifierProvider.notifier)
|
||||
.read(composeStorageProvider.notifier)
|
||||
.deleteDraft(composeState.draftId);
|
||||
|
||||
// Reset the form for new composition
|
||||
|
||||
@@ -47,7 +47,7 @@ class PostComposeDialog extends HookConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final drafts = ref.watch(composeStorageNotifierProvider);
|
||||
final drafts = ref.watch(composeStorageProvider);
|
||||
final restoredInitialState = useState<PostComposeInitialState?>(null);
|
||||
final prompted = useState(false);
|
||||
|
||||
@@ -166,7 +166,7 @@ class PostComposeDialog extends HookConsumerWidget {
|
||||
WidgetRef ref,
|
||||
ValueNotifier<PostComposeInitialState?> restoredInitialState,
|
||||
) async {
|
||||
final drafts = ref.read(composeStorageNotifierProvider);
|
||||
final drafts = ref.read(composeStorageProvider);
|
||||
if (drafts.isNotEmpty) {
|
||||
final latestDraft = drafts.values.last;
|
||||
|
||||
@@ -200,7 +200,7 @@ class PostComposeDialog extends HookConsumerWidget {
|
||||
if (restore == true) {
|
||||
// Delete the old draft
|
||||
await ref
|
||||
.read(composeStorageNotifierProvider.notifier)
|
||||
.read(composeStorageProvider.notifier)
|
||||
.deleteDraft(latestDraft.id);
|
||||
restoredInitialState.value = PostComposeInitialState(
|
||||
title: latestDraft.title,
|
||||
|
||||
@@ -22,7 +22,7 @@ class ComposeFundSheet extends HookConsumerWidget {
|
||||
final isPushing = useState(false);
|
||||
final errorText = useState<String?>(null);
|
||||
|
||||
final fundsData = ref.watch(walletFundsNotifierProvider);
|
||||
final fundsData = ref.watch(walletFundsProvider);
|
||||
|
||||
return SheetScaffold(
|
||||
heightFactor: 0.6,
|
||||
@@ -301,9 +301,7 @@ class ComposeFundSheet extends HookConsumerWidget {
|
||||
await Future.delayed(
|
||||
const Duration(seconds: 1),
|
||||
);
|
||||
ref.invalidate(
|
||||
walletFundsNotifierProvider,
|
||||
);
|
||||
ref.invalidate(walletFundsProvider);
|
||||
|
||||
// Return the created fund
|
||||
final updatedResp = await client.get(
|
||||
|
||||
@@ -18,8 +18,8 @@ final cloudFileListNotifierProvider =
|
||||
CloudFileListNotifier.new,
|
||||
);
|
||||
|
||||
class CloudFileListNotifier extends AutoDisposeAsyncNotifier<List<SnCloudFile>>
|
||||
with AutoDisposeAsyncPaginationController<SnCloudFile> {
|
||||
class CloudFileListNotifier extends AsyncNotifier<List<SnCloudFile>>
|
||||
with AsyncPaginationController<SnCloudFile> {
|
||||
@override
|
||||
Future<List<SnCloudFile>> fetch() async {
|
||||
final client = ref.read(apiClientProvider);
|
||||
|
||||
@@ -6,24 +6,46 @@ part of 'compose_settings_sheet.dart';
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$postCategoriesHash() => r'8799c10eb91cf8c8c7ea72eff3475e1eaa7b9a2b';
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
/// See also [postCategories].
|
||||
@ProviderFor(postCategories)
|
||||
final postCategoriesProvider =
|
||||
AutoDisposeFutureProvider<List<SnPostCategory>>.internal(
|
||||
postCategories,
|
||||
name: r'postCategoriesProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$postCategoriesHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
const postCategoriesProvider = PostCategoriesProvider._();
|
||||
|
||||
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||
// ignore: unused_element
|
||||
typedef PostCategoriesRef = AutoDisposeFutureProviderRef<List<SnPostCategory>>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||
final class PostCategoriesProvider
|
||||
extends
|
||||
$FunctionalProvider<
|
||||
AsyncValue<List<SnPostCategory>>,
|
||||
List<SnPostCategory>,
|
||||
FutureOr<List<SnPostCategory>>
|
||||
>
|
||||
with
|
||||
$FutureModifier<List<SnPostCategory>>,
|
||||
$FutureProvider<List<SnPostCategory>> {
|
||||
const PostCategoriesProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
retry: null,
|
||||
name: r'postCategoriesProvider',
|
||||
isAutoDispose: true,
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@override
|
||||
String debugGetCreateSourceHash() => _$postCategoriesHash();
|
||||
|
||||
@$internal
|
||||
@override
|
||||
$FutureProviderElement<List<SnPostCategory>> $createElement(
|
||||
$ProviderPointer pointer,
|
||||
) => $FutureProviderElement(pointer);
|
||||
|
||||
@override
|
||||
FutureOr<List<SnPostCategory>> create(Ref ref) {
|
||||
return postCategories(ref);
|
||||
}
|
||||
}
|
||||
|
||||
String _$postCategoriesHash() => r'8799c10eb91cf8c8c7ea72eff3475e1eaa7b9a2b';
|
||||
|
||||
@@ -272,7 +272,7 @@ class ComposeLogic {
|
||||
deletedAt: null,
|
||||
);
|
||||
|
||||
await ref.read(composeStorageNotifierProvider.notifier).saveDraft(draft);
|
||||
await ref.read(composeStorageProvider.notifier).saveDraft(draft);
|
||||
} catch (e) {
|
||||
talker.error('[ComposeLogic] Failed to save draft, error: $e');
|
||||
}
|
||||
@@ -345,7 +345,7 @@ class ComposeLogic {
|
||||
deletedAt: null,
|
||||
);
|
||||
|
||||
await ref.read(composeStorageNotifierProvider.notifier).saveDraft(draft);
|
||||
await ref.read(composeStorageProvider.notifier).saveDraft(draft);
|
||||
} catch (e) {
|
||||
talker.error(
|
||||
'[ComposeLogic] Failed to save draft without upload, error: $e',
|
||||
@@ -374,9 +374,7 @@ class ComposeLogic {
|
||||
|
||||
static Future<void> deleteDraft(WidgetRef ref, String draftId) async {
|
||||
try {
|
||||
await ref
|
||||
.read(composeStorageNotifierProvider.notifier)
|
||||
.deleteDraft(draftId);
|
||||
await ref.read(composeStorageProvider.notifier).deleteDraft(draftId);
|
||||
} catch (e) {
|
||||
// Silently fail
|
||||
}
|
||||
@@ -384,9 +382,7 @@ class ComposeLogic {
|
||||
|
||||
static Future<SnPost?> loadDraft(WidgetRef ref, String draftId) async {
|
||||
try {
|
||||
return ref
|
||||
.read(composeStorageNotifierProvider.notifier)
|
||||
.getDraft(draftId);
|
||||
return ref.read(composeStorageProvider.notifier).getDraft(draftId);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
@@ -778,12 +774,12 @@ class ComposeLogic {
|
||||
if (state.postType == 1) {
|
||||
// Delete article draft
|
||||
await ref
|
||||
.read(composeStorageNotifierProvider.notifier)
|
||||
.read(composeStorageProvider.notifier)
|
||||
.deleteDraft(state.draftId);
|
||||
} else {
|
||||
// Delete regular post draft
|
||||
await ref
|
||||
.read(composeStorageNotifierProvider.notifier)
|
||||
.read(composeStorageProvider.notifier)
|
||||
.deleteDraft(state.draftId);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class PostComposeSheet extends HookConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final drafts = ref.watch(composeStorageNotifierProvider);
|
||||
final drafts = ref.watch(composeStorageProvider);
|
||||
final restoredInitialState = useState<PostComposeInitialState?>(null);
|
||||
final prompted = useState(false);
|
||||
|
||||
@@ -185,7 +185,7 @@ class PostComposeSheet extends HookConsumerWidget {
|
||||
WidgetRef ref,
|
||||
ValueNotifier<PostComposeInitialState?> restoredInitialState,
|
||||
) async {
|
||||
final drafts = ref.read(composeStorageNotifierProvider);
|
||||
final drafts = ref.read(composeStorageProvider);
|
||||
if (drafts.isNotEmpty) {
|
||||
final latestDraft = drafts.values.last;
|
||||
|
||||
@@ -219,7 +219,7 @@ class PostComposeSheet extends HookConsumerWidget {
|
||||
if (restore == true) {
|
||||
// Delete the old draft
|
||||
await ref
|
||||
.read(composeStorageNotifierProvider.notifier)
|
||||
.read(composeStorageProvider.notifier)
|
||||
.deleteDraft(latestDraft.id);
|
||||
restoredInitialState.value = PostComposeInitialState(
|
||||
title: latestDraft.title,
|
||||
|
||||
@@ -60,7 +60,7 @@ class ComposeStateUtils {
|
||||
repliedPost == null &&
|
||||
initialState == null) {
|
||||
// Try to load the most recent draft
|
||||
final drafts = ref.read(composeStorageNotifierProvider);
|
||||
final drafts = ref.read(composeStorageProvider);
|
||||
if (drafts.isNotEmpty) {
|
||||
final mostRecentDraft = drafts.values.reduce(
|
||||
(a, b) =>
|
||||
@@ -128,7 +128,7 @@ class ComposeStateUtils {
|
||||
updatedAt: DateTime.now(),
|
||||
);
|
||||
ref
|
||||
.read(composeStorageNotifierProvider.notifier)
|
||||
.read(composeStorageProvider.notifier)
|
||||
.saveDraft(draft)
|
||||
.catchError((e) => debugPrint('Failed to save draft: $e'));
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ class ComposeToolbar extends HookConsumerWidget {
|
||||
builder:
|
||||
(context) => DraftManagerSheet(
|
||||
onDraftSelected: (draftId) {
|
||||
final draft = ref.read(composeStorageNotifierProvider)[draftId];
|
||||
final draft = ref.read(composeStorageProvider)[draftId];
|
||||
if (draft != null) {
|
||||
state.titleController.text = draft.title ?? '';
|
||||
state.descriptionController.text = draft.description ?? '';
|
||||
|
||||
@@ -20,7 +20,7 @@ class DraftManagerSheet extends HookConsumerWidget {
|
||||
final searchController = useTextEditingController();
|
||||
final searchQuery = useState('');
|
||||
|
||||
final drafts = ref.watch(composeStorageNotifierProvider);
|
||||
final drafts = ref.watch(composeStorageProvider);
|
||||
|
||||
// Search functionality
|
||||
final filteredDrafts = useMemoized(() {
|
||||
@@ -101,7 +101,7 @@ class DraftManagerSheet extends HookConsumerWidget {
|
||||
},
|
||||
onDelete: () async {
|
||||
await ref
|
||||
.read(composeStorageNotifierProvider.notifier)
|
||||
.read(composeStorageProvider.notifier)
|
||||
.deleteDraft(draft.id);
|
||||
},
|
||||
);
|
||||
@@ -127,7 +127,7 @@ class DraftManagerSheet extends HookConsumerWidget {
|
||||
|
||||
if (confirmed == true) {
|
||||
await ref
|
||||
.read(composeStorageNotifierProvider.notifier)
|
||||
.read(composeStorageProvider.notifier)
|
||||
.clearAllDrafts();
|
||||
}
|
||||
},
|
||||
|
||||
@@ -11,16 +11,18 @@ final postAwardListNotifierProvider = AsyncNotifierProvider.autoDispose
|
||||
PostAwardListNotifier.new,
|
||||
);
|
||||
|
||||
class PostAwardListNotifier
|
||||
extends AutoDisposeFamilyAsyncNotifier<List<SnPostAward>, String>
|
||||
with FamilyAsyncPaginationController<SnPostAward, String> {
|
||||
static const int _pageSize = 20;
|
||||
class PostAwardListNotifier extends AsyncNotifier<List<SnPostAward>>
|
||||
with AsyncPaginationController<SnPostAward> {
|
||||
static const int pageSize = 20;
|
||||
|
||||
final String arg;
|
||||
PostAwardListNotifier(this.arg);
|
||||
|
||||
@override
|
||||
Future<List<SnPostAward>> fetch() async {
|
||||
final client = ref.read(apiClientProvider);
|
||||
|
||||
final queryParams = {'offset': fetchedCount, 'take': _pageSize};
|
||||
final queryParams = {'offset': fetchedCount, 'take': pageSize};
|
||||
|
||||
final response = await client.get(
|
||||
'/sphere/posts/$arg/awards',
|
||||
@@ -50,7 +52,7 @@ class PostAwardHistorySheet extends HookConsumerWidget {
|
||||
return Column(
|
||||
children: [
|
||||
PostAwardItem(award: award),
|
||||
if (index < (ref.read(provider).valueOrNull?.length ?? 0) - 1)
|
||||
if (index < (ref.read(provider).value?.length ?? 0) - 1)
|
||||
const Divider(height: 1),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -6,23 +6,44 @@ part of 'post_featured.dart';
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$featuredPostsHash() => r'4b7fffb02eac72f5861b02af1b1e5da36b571698';
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
/// See also [featuredPosts].
|
||||
@ProviderFor(featuredPosts)
|
||||
final featuredPostsProvider = AutoDisposeFutureProvider<List<SnPost>>.internal(
|
||||
featuredPosts,
|
||||
name: r'featuredPostsProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$featuredPostsHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
const featuredPostsProvider = FeaturedPostsProvider._();
|
||||
|
||||
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||
// ignore: unused_element
|
||||
typedef FeaturedPostsRef = AutoDisposeFutureProviderRef<List<SnPost>>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||
final class FeaturedPostsProvider
|
||||
extends
|
||||
$FunctionalProvider<
|
||||
AsyncValue<List<SnPost>>,
|
||||
List<SnPost>,
|
||||
FutureOr<List<SnPost>>
|
||||
>
|
||||
with $FutureModifier<List<SnPost>>, $FutureProvider<List<SnPost>> {
|
||||
const FeaturedPostsProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
retry: null,
|
||||
name: r'featuredPostsProvider',
|
||||
isAutoDispose: true,
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@override
|
||||
String debugGetCreateSourceHash() => _$featuredPostsHash();
|
||||
|
||||
@$internal
|
||||
@override
|
||||
$FutureProviderElement<List<SnPost>> $createElement(
|
||||
$ProviderPointer pointer,
|
||||
) => $FutureProviderElement(pointer);
|
||||
|
||||
@override
|
||||
FutureOr<List<SnPost>> create(Ref ref) {
|
||||
return featuredPosts(ref);
|
||||
}
|
||||
}
|
||||
|
||||
String _$featuredPostsHash() => r'4b7fffb02eac72f5861b02af1b1e5da36b571698';
|
||||
|
||||
@@ -99,7 +99,7 @@ class PostActionableItem extends HookConsumerWidget {
|
||||
[user],
|
||||
);
|
||||
|
||||
final config = ref.watch(appSettingsNotifierProvider);
|
||||
final config = ref.watch(appSettingsProvider);
|
||||
|
||||
final widgetItem = InkWell(
|
||||
borderRadius:
|
||||
|
||||
@@ -35,10 +35,12 @@ final postListNotifierProvider = AsyncNotifierProvider.autoDispose
|
||||
PostListNotifier.new,
|
||||
);
|
||||
|
||||
class PostListNotifier
|
||||
extends AutoDisposeFamilyAsyncNotifier<List<SnPost>, PostListQuery>
|
||||
with FamilyAsyncPaginationController<SnPost, PostListQuery> {
|
||||
static const int _pageSize = 20;
|
||||
class PostListNotifier extends AsyncNotifier<List<SnPost>>
|
||||
with AsyncPaginationController<SnPost> {
|
||||
final PostListQuery arg;
|
||||
PostListNotifier(this.arg);
|
||||
|
||||
static const int pageSize = 20;
|
||||
|
||||
@override
|
||||
Future<List<SnPost>> fetch() async {
|
||||
@@ -46,7 +48,7 @@ class PostListNotifier
|
||||
|
||||
final queryParams = {
|
||||
'offset': fetchedCount,
|
||||
'take': _pageSize,
|
||||
'take': pageSize,
|
||||
'replies': arg.includeReplies,
|
||||
'orderDesc': arg.orderDesc,
|
||||
if (arg.shuffle) 'shuffle': arg.shuffle,
|
||||
|
||||
@@ -18,35 +18,29 @@ import 'package:material_symbols_icons/symbols.dart';
|
||||
import 'package:styled_widget/styled_widget.dart';
|
||||
import 'package:island/widgets/stickers/sticker_picker.dart';
|
||||
import 'package:island/pods/config.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
class ReactionListParams {
|
||||
final String symbol;
|
||||
final String postId;
|
||||
part 'post_reaction_sheet.freezed.dart';
|
||||
|
||||
const ReactionListParams({required this.symbol, required this.postId});
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is ReactionListParams &&
|
||||
runtimeType == other.runtimeType &&
|
||||
symbol == other.symbol &&
|
||||
postId == other.postId;
|
||||
|
||||
@override
|
||||
int get hashCode => symbol.hashCode ^ postId.hashCode;
|
||||
@freezed
|
||||
sealed class ReactionListQuery with _$ReactionListQuery {
|
||||
const factory ReactionListQuery({
|
||||
required String symbol,
|
||||
required String postId,
|
||||
}) = _ReactionListQuery;
|
||||
}
|
||||
|
||||
final reactionListNotifierProvider = AsyncNotifierProvider.autoDispose
|
||||
.family<ReactionListNotifier, List<SnPostReaction>, ReactionListParams>(
|
||||
.family<ReactionListNotifier, List<SnPostReaction>, ReactionListQuery>(
|
||||
ReactionListNotifier.new,
|
||||
);
|
||||
|
||||
class ReactionListNotifier
|
||||
extends
|
||||
AutoDisposeFamilyAsyncNotifier<List<SnPostReaction>, ReactionListParams>
|
||||
with FamilyAsyncPaginationController<SnPostReaction, ReactionListParams> {
|
||||
static const int _pageSize = 20;
|
||||
class ReactionListNotifier extends AsyncNotifier<List<SnPostReaction>>
|
||||
with AsyncPaginationController<SnPostReaction> {
|
||||
static const int pageSize = 20;
|
||||
|
||||
final ReactionListQuery arg;
|
||||
ReactionListNotifier(this.arg);
|
||||
|
||||
@override
|
||||
Future<List<SnPostReaction>> fetch() async {
|
||||
@@ -57,7 +51,7 @@ class ReactionListNotifier
|
||||
queryParameters: {
|
||||
'symbol': arg.symbol,
|
||||
'offset': fetchedCount,
|
||||
'take': _pageSize,
|
||||
'take': pageSize,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -488,7 +482,7 @@ class ReactionDetailsPopup extends HookConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final params = ReactionListParams(symbol: symbol, postId: postId);
|
||||
final params = ReactionListQuery(symbol: symbol, postId: postId);
|
||||
final provider = reactionListNotifierProvider(params);
|
||||
|
||||
final width = math.min(MediaQuery.of(context).size.width * 0.8, 480.0);
|
||||
|
||||
274
lib/widgets/post/post_reaction_sheet.freezed.dart
Normal file
274
lib/widgets/post/post_reaction_sheet.freezed.dart
Normal file
@@ -0,0 +1,274 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'post_reaction_sheet.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$ReactionListQuery {
|
||||
|
||||
String get symbol; String get postId;
|
||||
/// Create a copy of ReactionListQuery
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$ReactionListQueryCopyWith<ReactionListQuery> get copyWith => _$ReactionListQueryCopyWithImpl<ReactionListQuery>(this as ReactionListQuery, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ReactionListQuery&&(identical(other.symbol, symbol) || other.symbol == symbol)&&(identical(other.postId, postId) || other.postId == postId));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,symbol,postId);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ReactionListQuery(symbol: $symbol, postId: $postId)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $ReactionListQueryCopyWith<$Res> {
|
||||
factory $ReactionListQueryCopyWith(ReactionListQuery value, $Res Function(ReactionListQuery) _then) = _$ReactionListQueryCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String symbol, String postId
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$ReactionListQueryCopyWithImpl<$Res>
|
||||
implements $ReactionListQueryCopyWith<$Res> {
|
||||
_$ReactionListQueryCopyWithImpl(this._self, this._then);
|
||||
|
||||
final ReactionListQuery _self;
|
||||
final $Res Function(ReactionListQuery) _then;
|
||||
|
||||
/// Create a copy of ReactionListQuery
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? symbol = null,Object? postId = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
symbol: null == symbol ? _self.symbol : symbol // ignore: cast_nullable_to_non_nullable
|
||||
as String,postId: null == postId ? _self.postId : postId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [ReactionListQuery].
|
||||
extension ReactionListQueryPatterns on ReactionListQuery {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _ReactionListQuery value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ReactionListQuery() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _ReactionListQuery value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ReactionListQuery():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _ReactionListQuery value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ReactionListQuery() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String symbol, String postId)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ReactionListQuery() when $default != null:
|
||||
return $default(_that.symbol,_that.postId);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String symbol, String postId) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ReactionListQuery():
|
||||
return $default(_that.symbol,_that.postId);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String symbol, String postId)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ReactionListQuery() when $default != null:
|
||||
return $default(_that.symbol,_that.postId);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _ReactionListQuery implements ReactionListQuery {
|
||||
const _ReactionListQuery({required this.symbol, required this.postId});
|
||||
|
||||
|
||||
@override final String symbol;
|
||||
@override final String postId;
|
||||
|
||||
/// Create a copy of ReactionListQuery
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$ReactionListQueryCopyWith<_ReactionListQuery> get copyWith => __$ReactionListQueryCopyWithImpl<_ReactionListQuery>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ReactionListQuery&&(identical(other.symbol, symbol) || other.symbol == symbol)&&(identical(other.postId, postId) || other.postId == postId));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,symbol,postId);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ReactionListQuery(symbol: $symbol, postId: $postId)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$ReactionListQueryCopyWith<$Res> implements $ReactionListQueryCopyWith<$Res> {
|
||||
factory _$ReactionListQueryCopyWith(_ReactionListQuery value, $Res Function(_ReactionListQuery) _then) = __$ReactionListQueryCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String symbol, String postId
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$ReactionListQueryCopyWithImpl<$Res>
|
||||
implements _$ReactionListQueryCopyWith<$Res> {
|
||||
__$ReactionListQueryCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _ReactionListQuery _self;
|
||||
final $Res Function(_ReactionListQuery) _then;
|
||||
|
||||
/// Create a copy of ReactionListQuery
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? symbol = null,Object? postId = null,}) {
|
||||
return _then(_ReactionListQuery(
|
||||
symbol: null == symbol ? _self.symbol : symbol // ignore: cast_nullable_to_non_nullable
|
||||
as String,postId: null == postId ? _self.postId : postId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -6,13 +6,16 @@ import 'package:island/pods/paging.dart';
|
||||
import 'package:island/widgets/paging/pagination_list.dart';
|
||||
import 'package:island/widgets/post/post_item.dart';
|
||||
|
||||
final postRepliesNotifierProvider = AsyncNotifierProvider.autoDispose
|
||||
.family<PostRepliesNotifier, List<SnPost>, String>(PostRepliesNotifier.new);
|
||||
final postRepliesProvider = AsyncNotifierProvider.autoDispose.family(
|
||||
PostRepliesNotifier.new,
|
||||
);
|
||||
|
||||
class PostRepliesNotifier
|
||||
extends AutoDisposeFamilyAsyncNotifier<List<SnPost>, String>
|
||||
with FamilyAsyncPaginationController<SnPost, String> {
|
||||
static const int _pageSize = 20;
|
||||
class PostRepliesNotifier extends AsyncNotifier<List<SnPost>>
|
||||
with AsyncPaginationController<SnPost> {
|
||||
static const int pageSize = 20;
|
||||
|
||||
final String arg;
|
||||
PostRepliesNotifier(this.arg);
|
||||
|
||||
@override
|
||||
Future<List<SnPost>> fetch() async {
|
||||
@@ -20,7 +23,7 @@ class PostRepliesNotifier
|
||||
|
||||
final response = await client.get(
|
||||
'/sphere/posts/$arg/replies',
|
||||
queryParameters: {'offset': fetchedCount, 'take': _pageSize},
|
||||
queryParameters: {'offset': fetchedCount, 'take': pageSize},
|
||||
);
|
||||
|
||||
totalCount = int.parse(response.headers.value('X-Total') ?? '0');
|
||||
@@ -42,7 +45,7 @@ class PostRepliesList extends HookConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final provider = postRepliesNotifierProvider(postId);
|
||||
final provider = postRepliesProvider(postId);
|
||||
|
||||
return PaginationList(
|
||||
provider: provider,
|
||||
|
||||
@@ -41,7 +41,7 @@ class PostRepliesSheet extends HookConsumerWidget {
|
||||
child: PostQuickReply(
|
||||
parent: post,
|
||||
onPosted: () {
|
||||
ref.invalidate(postRepliesNotifierProvider(post.id));
|
||||
ref.invalidate(postRepliesProvider(post.id));
|
||||
},
|
||||
onLaunch: () {
|
||||
Navigator.of(context).pop();
|
||||
|
||||
@@ -115,7 +115,7 @@ class PostReplyPreview extends HookConsumerWidget {
|
||||
}, [parent]);
|
||||
|
||||
final featuredReply =
|
||||
isOpenable ? null : ref.watch(PostFeaturedReplyProvider(parent.id));
|
||||
isOpenable ? null : ref.watch(postFeaturedReplyProvider(parent.id));
|
||||
|
||||
final itemWidget =
|
||||
isOpenable
|
||||
|
||||
@@ -6,147 +6,74 @@ part of 'post_shared.dart';
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$postFeaturedReplyHash() => r'3f0ac0d51ad21f8754a63dd94109eb8ac4812293';
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
_SystemHash._();
|
||||
|
||||
static int combine(int hash, int value) {
|
||||
// ignore: parameter_assignments
|
||||
hash = 0x1fffffff & (hash + value);
|
||||
// ignore: parameter_assignments
|
||||
hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10));
|
||||
return hash ^ (hash >> 6);
|
||||
}
|
||||
|
||||
static int finish(int hash) {
|
||||
// ignore: parameter_assignments
|
||||
hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3));
|
||||
// ignore: parameter_assignments
|
||||
hash = hash ^ (hash >> 11);
|
||||
return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
|
||||
}
|
||||
}
|
||||
|
||||
/// See also [postFeaturedReply].
|
||||
@ProviderFor(postFeaturedReply)
|
||||
const postFeaturedReplyProvider = PostFeaturedReplyFamily();
|
||||
const postFeaturedReplyProvider = PostFeaturedReplyFamily._();
|
||||
|
||||
/// See also [postFeaturedReply].
|
||||
class PostFeaturedReplyFamily extends Family<AsyncValue<SnPost?>> {
|
||||
/// See also [postFeaturedReply].
|
||||
const PostFeaturedReplyFamily();
|
||||
final class PostFeaturedReplyProvider
|
||||
extends $FunctionalProvider<AsyncValue<SnPost?>, SnPost?, FutureOr<SnPost?>>
|
||||
with $FutureModifier<SnPost?>, $FutureProvider<SnPost?> {
|
||||
const PostFeaturedReplyProvider._({
|
||||
required PostFeaturedReplyFamily super.from,
|
||||
required String super.argument,
|
||||
}) : super(
|
||||
retry: null,
|
||||
name: r'postFeaturedReplyProvider',
|
||||
isAutoDispose: true,
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
/// See also [postFeaturedReply].
|
||||
PostFeaturedReplyProvider call(String id) {
|
||||
return PostFeaturedReplyProvider(id);
|
||||
@override
|
||||
String debugGetCreateSourceHash() => _$postFeaturedReplyHash();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return r'postFeaturedReplyProvider'
|
||||
''
|
||||
'($argument)';
|
||||
}
|
||||
|
||||
@$internal
|
||||
@override
|
||||
PostFeaturedReplyProvider getProviderOverride(
|
||||
covariant PostFeaturedReplyProvider provider,
|
||||
) {
|
||||
return call(provider.id);
|
||||
}
|
||||
|
||||
static const Iterable<ProviderOrFamily>? _dependencies = null;
|
||||
$FutureProviderElement<SnPost?> $createElement($ProviderPointer pointer) =>
|
||||
$FutureProviderElement(pointer);
|
||||
|
||||
@override
|
||||
Iterable<ProviderOrFamily>? get dependencies => _dependencies;
|
||||
|
||||
static const Iterable<ProviderOrFamily>? _allTransitiveDependencies = null;
|
||||
|
||||
@override
|
||||
Iterable<ProviderOrFamily>? get allTransitiveDependencies =>
|
||||
_allTransitiveDependencies;
|
||||
|
||||
@override
|
||||
String? get name => r'postFeaturedReplyProvider';
|
||||
}
|
||||
|
||||
/// See also [postFeaturedReply].
|
||||
class PostFeaturedReplyProvider extends AutoDisposeFutureProvider<SnPost?> {
|
||||
/// See also [postFeaturedReply].
|
||||
PostFeaturedReplyProvider(String id)
|
||||
: this._internal(
|
||||
(ref) => postFeaturedReply(ref as PostFeaturedReplyRef, id),
|
||||
from: postFeaturedReplyProvider,
|
||||
name: r'postFeaturedReplyProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$postFeaturedReplyHash,
|
||||
dependencies: PostFeaturedReplyFamily._dependencies,
|
||||
allTransitiveDependencies:
|
||||
PostFeaturedReplyFamily._allTransitiveDependencies,
|
||||
id: id,
|
||||
);
|
||||
|
||||
PostFeaturedReplyProvider._internal(
|
||||
super._createNotifier, {
|
||||
required super.name,
|
||||
required super.dependencies,
|
||||
required super.allTransitiveDependencies,
|
||||
required super.debugGetCreateSourceHash,
|
||||
required super.from,
|
||||
required this.id,
|
||||
}) : super.internal();
|
||||
|
||||
final String id;
|
||||
|
||||
@override
|
||||
Override overrideWith(
|
||||
FutureOr<SnPost?> Function(PostFeaturedReplyRef provider) create,
|
||||
) {
|
||||
return ProviderOverride(
|
||||
origin: this,
|
||||
override: PostFeaturedReplyProvider._internal(
|
||||
(ref) => create(ref as PostFeaturedReplyRef),
|
||||
from: from,
|
||||
name: null,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
debugGetCreateSourceHash: null,
|
||||
id: id,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
AutoDisposeFutureProviderElement<SnPost?> createElement() {
|
||||
return _PostFeaturedReplyProviderElement(this);
|
||||
FutureOr<SnPost?> create(Ref ref) {
|
||||
final argument = this.argument as String;
|
||||
return postFeaturedReply(ref, argument);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return other is PostFeaturedReplyProvider && other.id == id;
|
||||
return other is PostFeaturedReplyProvider && other.argument == argument;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
var hash = _SystemHash.combine(0, runtimeType.hashCode);
|
||||
hash = _SystemHash.combine(hash, id.hashCode);
|
||||
|
||||
return _SystemHash.finish(hash);
|
||||
return argument.hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||
// ignore: unused_element
|
||||
mixin PostFeaturedReplyRef on AutoDisposeFutureProviderRef<SnPost?> {
|
||||
/// The parameter `id` of this provider.
|
||||
String get id;
|
||||
}
|
||||
String _$postFeaturedReplyHash() => r'3f0ac0d51ad21f8754a63dd94109eb8ac4812293';
|
||||
|
||||
class _PostFeaturedReplyProviderElement
|
||||
extends AutoDisposeFutureProviderElement<SnPost?>
|
||||
with PostFeaturedReplyRef {
|
||||
_PostFeaturedReplyProviderElement(super.provider);
|
||||
final class PostFeaturedReplyFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<SnPost?>, String> {
|
||||
const PostFeaturedReplyFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'postFeaturedReplyProvider',
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
isAutoDispose: true,
|
||||
);
|
||||
|
||||
PostFeaturedReplyProvider call(String id) =>
|
||||
PostFeaturedReplyProvider._(argument: id, from: this);
|
||||
|
||||
@override
|
||||
String get id => (origin as PostFeaturedReplyProvider).id;
|
||||
String toString() => r'postFeaturedReplyProvider';
|
||||
}
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||
|
||||
@@ -38,9 +38,9 @@ class PostShuffleScreen extends HookConsumerWidget {
|
||||
kBottomControlHeight + MediaQuery.of(context).padding.bottom,
|
||||
),
|
||||
child: Builder(
|
||||
key: ValueKey(postListState.valueOrNull?.length ?? 0),
|
||||
key: ValueKey(postListState.value?.length ?? 0),
|
||||
builder: (context) {
|
||||
final items = postListState.valueOrNull ?? [];
|
||||
final items = postListState.value ?? [];
|
||||
if (items.isNotEmpty) {
|
||||
return CardSwiper(
|
||||
controller: cardSwiperController,
|
||||
|
||||
Reference in New Issue
Block a user