🐛 Fix search post did not triggered

This commit is contained in:
LittleSheep 2024-12-22 20:28:53 +08:00
parent 7a3ab6fd7d
commit 3eda464e03

View File

@ -99,11 +99,16 @@ class _PostSearchScreenState extends State<PostSearchScreen> {
], ],
).padding(horizontal: 24, vertical: 16), ).padding(horizontal: 24, vertical: 16),
).then((_) { ).then((_) {
_posts.clear(); _refreshPosts();
_fetchPosts();
}); });
} }
Future<void> _refreshPosts() {
_postCount = null;
_posts.clear();
return _fetchPosts();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
const labelShadows = <Shadow>[ const labelShadows = <Shadow>[
@ -144,8 +149,7 @@ class _PostSearchScreenState extends State<PostSearchScreen> {
setState(() => _posts[idx] = data); setState(() => _posts[idx] = data);
}, },
onDeleted: () { onDeleted: () {
_posts.clear(); _refreshPosts();
_fetchPosts();
}, },
), ),
onTap: () { onTap: () {
@ -176,10 +180,8 @@ class _PostSearchScreenState extends State<PostSearchScreen> {
_searchTerm = value; _searchTerm = value;
}, },
onSubmitted: (value) { onSubmitted: (value) {
setState(() => _posts.clear());
_searchTerm = value; _searchTerm = value;
_fetchPosts(); _refreshPosts();
}, },
), ),
if (_lastTook != null) if (_lastTook != null)