Optimize and fixes

This commit is contained in:
2024-08-04 18:13:59 +08:00
parent 12102bf527
commit a157596a2e
10 changed files with 117 additions and 67 deletions

View File

@ -97,13 +97,13 @@ class _PostActionState extends State<PostAction> {
leading: const FaIcon(FontAwesomeIcons.reply, size: 20),
title: Text('reply'.tr),
onTap: () async {
final value = await AppRouter.instance.pushNamed(
'postEditor',
extra: PostPublishArguments(reply: widget.item),
Navigator.pop(
context,
AppRouter.instance.pushNamed(
'postEditor',
extra: PostPublishArguments(reply: widget.item),
),
);
if (value != null) {
Navigator.pop(context, true);
}
},
),
if (!widget.noReact)
@ -112,13 +112,13 @@ class _PostActionState extends State<PostAction> {
leading: const FaIcon(FontAwesomeIcons.retweet, size: 20),
title: Text('repost'.tr),
onTap: () async {
final value = await AppRouter.instance.pushNamed(
'postEditor',
extra: PostPublishArguments(repost: widget.item),
Navigator.pop(
context,
AppRouter.instance.pushNamed(
'postEditor',
extra: PostPublishArguments(repost: widget.item),
),
);
if (value != null) {
Navigator.pop(context, true);
}
},
),
if (_canModifyContent && !widget.noReact)
@ -146,13 +146,13 @@ class _PostActionState extends State<PostAction> {
leading: const Icon(Icons.edit),
title: Text('edit'.tr),
onTap: () async {
final value = await AppRouter.instance.pushNamed(
'postEditor',
extra: PostPublishArguments(edit: widget.item),
Navigator.pop(
context,
AppRouter.instance.pushNamed(
'postEditor',
extra: PostPublishArguments(edit: widget.item),
),
);
if (value != null) {
Navigator.pop(context, true);
}
},
),
if (_canModifyContent)

View File

@ -85,7 +85,13 @@ class PostListEntryWidget extends StatelessWidget {
context: context,
builder: (context) => PostAction(item: item),
).then((value) {
if (value != null) onUpdate();
if (value is Future) {
value.then((_) {
onUpdate();
});
} else if (value != null) {
onUpdate();
}
});
},
);

View File

@ -9,6 +9,7 @@ class PostWarpedListWidget extends StatelessWidget {
final bool isNestedClickable;
final bool isPinned;
final PagingController<int, Post> controller;
final Function? onUpdate;
const PostWarpedListWidget({
super.key,
@ -17,6 +18,7 @@ class PostWarpedListWidget extends StatelessWidget {
this.isClickable = true,
this.isNestedClickable = true,
this.isPinned = true,
this.onUpdate,
});
@override
@ -35,9 +37,7 @@ class PostWarpedListWidget extends StatelessWidget {
isNestedClickable: isNestedClickable,
isClickable: isClickable,
item: item,
onUpdate: () {
controller.refresh();
},
onUpdate: onUpdate ?? () {},
);
},
),