Browse Source

neon: Fix parallel awaits

pull/146/head
jld3103 2 years ago
parent
commit
00d002e60a
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 44
      packages/neon/lib/src/apps/news/blocs/news.dart
  2. 6
      packages/neon/lib/src/apps/news/widgets/articles_view.dart

44
packages/neon/lib/src/apps/news/blocs/news.dart

@ -95,27 +95,29 @@ class NewsBloc extends InteractiveBloc implements NewsBlocEvents, NewsBlocStates
@override
Future refresh() async {
await requestManager.wrapNextcloud<List<NewsFolder>, NewsListFolders>(
client.id,
'news-folders',
folders,
() async => client.news.listFolders(),
(final response) => response.folders,
);
await requestManager.wrapNextcloud<List<NewsFeed>, NewsListFeeds>(
client.id,
'news-feeds',
feeds,
() async => client.news.listFeeds(),
(final response) {
// This is a bit ugly, but IDGAF right now
if (response.newestItemId != null) {
_newestItemId = response.newestItemId!;
}
return response.feeds;
},
);
await mainArticlesBloc.reload();
await Future.wait([
requestManager.wrapNextcloud<List<NewsFolder>, NewsListFolders>(
client.id,
'news-folders',
folders,
() async => client.news.listFolders(),
(final response) => response.folders,
),
requestManager.wrapNextcloud<List<NewsFeed>, NewsListFeeds>(
client.id,
'news-feeds',
feeds,
() async => client.news.listFeeds(),
(final response) {
// This is a bit ugly, but IDGAF right now
if (response.newestItemId != null) {
_newestItemId = response.newestItemId!;
}
return response.feeds;
},
),
mainArticlesBloc.reload(),
]);
}
@override

6
packages/neon/lib/src/apps/news/widgets/articles_view.dart

@ -42,8 +42,10 @@ class _NewsArticlesViewState extends State<NewsArticlesView> {
isLoading: articles.loading || feeds.loading,
error: articles.error ?? feeds.error,
onRefresh: () async {
await widget.bloc.refresh();
await widget.newsBloc.refresh();
await Future.wait([
widget.bloc.refresh(),
widget.newsBloc.refresh(),
]);
},
builder: (final context, final article) => _buildArticle(
context,

Loading…
Cancel
Save