silly stuff. constructor simplification. remove mistake

This commit is contained in:
Filip Krawczyk 2021-10-19 23:42:28 +02:00
parent fb78c5654b
commit f9d657cac6
1 changed files with 88 additions and 117 deletions

View File

@ -25,24 +25,7 @@ import 'full_post_store.dart';
/// Displays a post with its comment section /// Displays a post with its comment section
class FullPostPage extends HookWidget { class FullPostPage extends HookWidget {
final String? instanceHost; const FullPostPage._();
final int? id;
final PostView? postView;
final PostStore? postStore;
const FullPostPage._({
required int this.id,
required String this.instanceHost,
}) : postView = null,
postStore = null;
const FullPostPage._fromPostView(PostView this.postView)
: id = null,
instanceHost = null,
postStore = null;
const FullPostPage._fromPostStore(PostStore this.postStore)
: id = null,
instanceHost = null,
postView = null;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -52,14 +35,6 @@ class FullPostPage extends HookWidget {
useLoggedInAction(context.read<FullPostStore>().instanceHost); useLoggedInAction(context.read<FullPostStore>().instanceHost);
return AsyncStoreListener( return AsyncStoreListener(
asyncStore: context.read<FullPostStore>().fullPostState,
child: AsyncStoreListener<BlockedCommunity>(
asyncStore: context.read<FullPostStore>().communityBlockingState,
successMessageBuilder: (context, data) {
final name = data.communityView.community.originPreferredName;
return '${data.blocked ? 'Blocked' : 'Unblocked'} $name';
},
child: AsyncStoreListener(
asyncStore: context.read<FullPostStore>().fullPostState, asyncStore: context.read<FullPostStore>().fullPostState,
child: AsyncStoreListener<BlockedCommunity>( child: AsyncStoreListener<BlockedCommunity>(
asyncStore: context.read<FullPostStore>().communityBlockingState, asyncStore: context.read<FullPostStore>().communityBlockingState,
@ -155,8 +130,6 @@ class FullPostPage extends HookWidget {
}, },
), ),
), ),
),
),
); );
} }
@ -169,10 +142,7 @@ class FullPostPage extends HookWidget {
create: (context) => create: (context) =>
FullPostStore(instanceHost: instanceHost, postId: id) FullPostStore(instanceHost: instanceHost, postId: id)
..refresh(_tryGetJwt(context, instanceHost)), ..refresh(_tryGetJwt(context, instanceHost)),
child: FullPostPage._( child: const FullPostPage._(),
id: id,
instanceHost: instanceHost,
),
), ),
); );
@ -180,14 +150,15 @@ class FullPostPage extends HookWidget {
builder: (context) => Provider( builder: (context) => Provider(
create: (context) => FullPostStore.fromPostView(postView) create: (context) => FullPostStore.fromPostView(postView)
..refresh(_tryGetJwt(context, postView.instanceHost)), ..refresh(_tryGetJwt(context, postView.instanceHost)),
child: FullPostPage._fromPostView(postView), child: const FullPostPage._(),
), ),
); );
static Route fromPostStoreRoute(PostStore postStore) => MaterialPageRoute( static Route fromPostStoreRoute(PostStore postStore) => MaterialPageRoute(
builder: (context) => Provider( builder: (context) => Provider(
create: (context) => FullPostStore.fromPostStore(postStore) create: (context) => FullPostStore.fromPostStore(postStore)
..refresh(_tryGetJwt(context, postStore.postView.instanceHost)), ..refresh(_tryGetJwt(context, postStore.postView.instanceHost)),
child: FullPostPage._fromPostStore(postStore)), child: const FullPostPage._(),
),
); );
} }