From 00d002e60ab095d1ae44562287c20454f6d21cbc Mon Sep 17 00:00:00 2001 From: jld3103 Date: Thu, 8 Dec 2022 13:33:00 +0100 Subject: [PATCH] neon: Fix parallel awaits --- .../neon/lib/src/apps/news/blocs/news.dart | 44 ++++++++++--------- .../src/apps/news/widgets/articles_view.dart | 6 ++- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/packages/neon/lib/src/apps/news/blocs/news.dart b/packages/neon/lib/src/apps/news/blocs/news.dart index bb4882fd..f396b116 100644 --- a/packages/neon/lib/src/apps/news/blocs/news.dart +++ b/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, NewsListFolders>( - client.id, - 'news-folders', - folders, - () async => client.news.listFolders(), - (final response) => response.folders, - ); - await requestManager.wrapNextcloud, 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, NewsListFolders>( + client.id, + 'news-folders', + folders, + () async => client.news.listFolders(), + (final response) => response.folders, + ), + requestManager.wrapNextcloud, 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 diff --git a/packages/neon/lib/src/apps/news/widgets/articles_view.dart b/packages/neon/lib/src/apps/news/widgets/articles_view.dart index 13fd7af8..9b77578b 100644 --- a/packages/neon/lib/src/apps/news/widgets/articles_view.dart +++ b/packages/neon/lib/src/apps/news/widgets/articles_view.dart @@ -42,8 +42,10 @@ class _NewsArticlesViewState extends State { 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,