Browse Source

Merge pull request #146 from provokateurin/cleanup/blocs

Cleanup blocs
pull/147/head
Kate 2 years ago committed by GitHub
parent
commit
ac453ee2f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      packages/neon/lib/src/apps/files/widgets/browser_view.dart
  2. 12
      packages/neon/lib/src/apps/news/blocs/news.dart
  3. 4
      packages/neon/lib/src/apps/news/dialogs/add_feed.dart
  4. 10
      packages/neon/lib/src/apps/news/widgets/articles_view.dart
  5. 7
      packages/neon/lib/src/apps/news/widgets/feeds_view.dart
  6. 7
      packages/neon/lib/src/apps/news/widgets/folders_view.dart
  7. 4
      packages/neon/lib/src/apps/notes/dialogs/create_note.dart
  8. 4
      packages/neon/lib/src/apps/notes/dialogs/select_category.dart
  9. 7
      packages/neon/lib/src/apps/notes/widgets/categories_view.dart
  10. 7
      packages/neon/lib/src/apps/notes/widgets/notes_view.dart
  11. 7
      packages/neon/lib/src/apps/notifications/pages/main.dart
  12. 4
      packages/neon/lib/src/pages/account_settings.dart
  13. 12
      packages/neon/lib/src/pages/home.dart
  14. 14
      packages/neon/lib/src/pages/login.dart
  15. 4
      packages/neon/lib/src/widgets/account_tile.dart
  16. 4
      packages/neon/lib/src/widgets/custom_listview.dart

7
packages/neon/lib/src/apps/files/widgets/browser_view.dart

@ -141,12 +141,7 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
],
isLoading: files.loading,
error: files.error,
onRetry: () async {
await widget.bloc.refresh();
},
onRefresh: () async {
await widget.bloc.refresh();
},
onRefresh: widget.bloc.refresh,
builder: (final context, final widget) => widget,
topScrollingChildren: [
Align(

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

@ -95,14 +95,15 @@ class NewsBloc extends InteractiveBloc implements NewsBlocEvents, NewsBlocStates
@override
Future refresh() async {
await requestManager.wrapNextcloud<List<NewsFolder>, NewsListFolders>(
await Future.wait([
requestManager.wrapNextcloud<List<NewsFolder>, NewsListFolders>(
client.id,
'news-folders',
folders,
() async => client.news.listFolders(),
(final response) => response.folders,
);
await requestManager.wrapNextcloud<List<NewsFeed>, NewsListFeeds>(
),
requestManager.wrapNextcloud<List<NewsFeed>, NewsListFeeds>(
client.id,
'news-feeds',
feeds,
@ -114,8 +115,9 @@ class NewsBloc extends InteractiveBloc implements NewsBlocEvents, NewsBlocStates
}
return response.feeds;
},
);
await mainArticlesBloc.reload();
),
mainArticlesBloc.reload(),
]);
}
@override

4
packages/neon/lib/src/apps/news/dialogs/add_feed.dart

@ -68,9 +68,7 @@ class _NewsAddFeedDialogState extends State<NewsAddFeedDialog> {
Center(
child: ExceptionWidget(
folders.error,
onRetry: () async {
await widget.bloc.refresh();
},
onRetry: widget.bloc.refresh,
),
),
Center(

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

@ -41,13 +41,11 @@ class _NewsArticlesViewState extends State<NewsArticlesView> {
items: feeds.data == null ? null : sorted,
isLoading: articles.loading || feeds.loading,
error: articles.error ?? feeds.error,
onRetry: () async {
await widget.bloc.refresh();
await widget.newsBloc.refresh();
},
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,

7
packages/neon/lib/src/apps/news/widgets/feeds_view.dart

@ -45,12 +45,7 @@ class NewsFeedsView extends StatelessWidget {
items: sorted,
isLoading: feeds.loading || folders.loading,
error: feeds.error ?? folders.error,
onRetry: () async {
await bloc.refresh();
},
onRefresh: () async {
await bloc.refresh();
},
onRefresh: bloc.refresh,
builder: (final context, final feed) => _buildFeed(
context,
feed,

7
packages/neon/lib/src/apps/news/widgets/folders_view.dart

@ -47,12 +47,7 @@ class NewsFoldersView extends StatelessWidget {
items: sorted,
isLoading: feeds.loading || folders.loading,
error: feeds.error ?? folders.error,
onRetry: () async {
await bloc.refresh();
},
onRefresh: () async {
await bloc.refresh();
},
onRefresh: bloc.refresh,
builder: _buildFolder,
),
),

4
packages/neon/lib/src/apps/notes/dialogs/create_note.dart

@ -51,9 +51,7 @@ class _NotesCreateNoteDialogState extends State<NotesCreateNoteDialog> {
Center(
child: ExceptionWidget(
notes.error,
onRetry: () async {
await widget.bloc.refresh();
},
onRetry: widget.bloc.refresh,
),
),
Center(

4
packages/neon/lib/src/apps/notes/dialogs/select_category.dart

@ -39,9 +39,7 @@ class _NotesSelectCategoryDialogState extends State<NotesSelectCategoryDialog> {
Center(
child: ExceptionWidget(
notes.error,
onRetry: () async {
await widget.bloc.refresh();
},
onRetry: widget.bloc.refresh,
),
),
Center(

7
packages/neon/lib/src/apps/notes/widgets/categories_view.dart

@ -30,12 +30,7 @@ class NotesCategoriesView extends StatelessWidget {
items: sorted,
isLoading: notes.loading,
error: notes.error,
onRetry: () async {
await bloc.refresh();
},
onRefresh: () async {
await bloc.refresh();
},
onRefresh: bloc.refresh,
builder: _buildCategory,
),
),

7
packages/neon/lib/src/apps/notes/widgets/notes_view.dart

@ -60,12 +60,7 @@ class NotesView extends StatelessWidget {
],
isLoading: notes.loading,
error: notes.error,
onRetry: () async {
await bloc.refresh();
},
onRefresh: () async {
await bloc.refresh();
},
onRefresh: bloc.refresh,
builder: _buildNote,
),
),

7
packages/neon/lib/src/apps/notifications/pages/main.dart

@ -39,12 +39,7 @@ class _NotificationsMainPageState extends State<NotificationsMainPage> {
items: notifications.data,
isLoading: notifications.loading,
error: notifications.error,
onRetry: () async {
await widget.bloc.refresh();
},
onRefresh: () async {
await widget.bloc.refresh();
},
onRefresh: widget.bloc.refresh,
builder: _buildNotification,
),
),

4
packages/neon/lib/src/pages/account_settings.dart

@ -74,9 +74,7 @@ class AccountSettingsPage extends StatelessWidget {
],
ExceptionWidget(
userDetails.error,
onRetry: () async {
await _userDetailsBloc.refresh();
},
onRetry: _userDetailsBloc.refresh,
),
CustomLinearProgressIndicator(
visible: userDetails.loading,

12
packages/neon/lib/src/pages/home.dart

@ -254,9 +254,7 @@ class _HomePageState extends State<HomePage> {
] else ...[
ExceptionWidget(
capabilities.error,
onRetry: () async {
await _capabilitiesBloc.refresh();
},
onRetry: _capabilitiesBloc.refresh,
),
CustomLinearProgressIndicator(
visible: capabilities.loading,
@ -303,9 +301,7 @@ class _HomePageState extends State<HomePage> {
ExceptionWidget(
appImplementations.error,
onlyIcon: isQuickBar,
onRetry: () async {
await _appsBloc.refresh();
},
onRetry: _appsBloc.refresh,
),
CustomLinearProgressIndicator(
visible: appImplementations.loading,
@ -539,9 +535,7 @@ class _HomePageState extends State<HomePage> {
children: [
ExceptionWidget(
appImplementations.error,
onRetry: () async {
await _appsBloc.refresh();
},
onRetry: _appsBloc.refresh,
),
if (appImplementations.data != null) ...[
if (appImplementations.data!.isEmpty) ...[

14
packages/neon/lib/src/pages/login.dart

@ -66,7 +66,7 @@ class _LoginPageState extends State<LoginPage> {
for (final a in accountsBloc.accounts.value) {
if (a.id == account.id) {
ExceptionWidget.showSnackbar(context, AppLocalizations.of(context).errorAccountAlreadyExists);
_loginBloc.setServerURL(result.server);
await _loginBloc.refresh();
return;
}
}
@ -168,9 +168,7 @@ class _LoginPageState extends State<LoginPage> {
height: 10,
),
ElevatedButton(
onPressed: () {
_loginBloc.setServerURL(serverURLSnapshot.data!);
},
onPressed: _loginBloc.refresh,
child: Text(AppLocalizations.of(context).loginOpenAgain),
),
],
@ -224,17 +222,13 @@ class _LoginPageState extends State<LoginPage> {
if (serverConnectionStateSnapshot.data == ServerConnectionState.unreachable) ...[
ExceptionWidget(
AppLocalizations.of(context).errorUnableToReachServer,
onRetry: () {
_loginBloc.setServerURL(serverURLSnapshot.data);
},
onRetry: _loginBloc.refresh,
),
],
if (serverConnectionStateSnapshot.data == ServerConnectionState.maintenanceMode) ...[
ExceptionWidget(
AppLocalizations.of(context).errorServerInMaintenanceMode,
onRetry: () {
_loginBloc.setServerURL(serverURLSnapshot.data);
},
onRetry: _loginBloc.refresh,
),
],
],

4
packages/neon/lib/src/widgets/account_tile.dart

@ -71,9 +71,7 @@ class AccountTile extends StatelessWidget {
userDetails.error!,
onlyIcon: true,
iconSize: 24,
onRetry: () async {
await userDetailsBloc.refresh();
},
onRetry: userDetailsBloc.refresh,
),
],
],

4
packages/neon/lib/src/widgets/custom_listview.dart

@ -5,7 +5,6 @@ class CustomListView<T> extends StatelessWidget {
required this.items,
required this.isLoading,
required this.error,
required this.onRetry,
required this.onRefresh,
required this.builder,
this.scrollKey,
@ -18,7 +17,6 @@ class CustomListView<T> extends StatelessWidget {
final List<T>? items;
final bool isLoading;
final dynamic error;
final Function() onRetry;
final Future Function() onRefresh;
final Widget Function(BuildContext, T data) builder;
final String? scrollKey;
@ -52,7 +50,7 @@ class CustomListView<T> extends StatelessWidget {
],
ExceptionWidget(
error,
onRetry: onRetry,
onRetry: onRefresh,
),
if (items != null) ...[
for (final item in items!) ...[

Loading…
Cancel
Save