Skip to content

Commit

Permalink
fixup! refactor: Make bloc implementations private
Browse files Browse the repository at this point in the history
  • Loading branch information
provokateurin committed Dec 23, 2023
1 parent e3da727 commit 0cd0bc2
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/neon/neon_dashboard/lib/src/pages/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class DashboardMainPage extends StatelessWidget {
scrollKey: 'dashboard',
isLoading: snapshot.isLoading,
error: snapshot.error,
onRefresh: bloc.refresh,
onRefresh: () async => bloc.refresh(),
sliver: SliverFillRemaining(
hasScrollBody: false,
child: Center(
Expand Down
2 changes: 1 addition & 1 deletion packages/neon/neon_files/lib/src/widgets/browser_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
},
isLoading: filesSnapshot.isLoading,
error: filesSnapshot.error,
onRefresh: widget.bloc.refresh,
onRefresh: () async => widget.bloc.refresh(),
topScrollingChildren: [
FilesBrowserNavigator(
uri: uriSnapshot.requireData,
Expand Down
6 changes: 2 additions & 4 deletions packages/neon/neon_news/lib/src/widgets/articles_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ class _NewsArticlesViewState extends State<NewsArticlesView> {
isLoading: articles.isLoading || feeds.isLoading,
error: articles.error ?? feeds.error,
onRefresh: () async {
await Future.wait([
widget.bloc.refresh(),
widget.newsBloc.refresh(),
]);
await widget.bloc.refresh();
await widget.newsBloc.refresh();
},
itemCount: feeds.hasData ? sorted.length : null,
itemBuilder: (final context, final index) {
Expand Down
2 changes: 1 addition & 1 deletion packages/neon/neon_news/lib/src/widgets/feeds_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class NewsFeedsView extends StatelessWidget {
scrollKey: 'news-feeds',
isLoading: feeds.isLoading || folders.isLoading,
error: feeds.error ?? folders.error,
onRefresh: bloc.refresh,
onRefresh: () async => bloc.refresh(),
itemCount: sorted.length,
itemBuilder: (final context, final index) => _buildFeed(
context,
Expand Down
2 changes: 1 addition & 1 deletion packages/neon/neon_news/lib/src/widgets/folders_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class NewsFoldersView extends StatelessWidget {
scrollKey: 'news-folders',
isLoading: feeds.isLoading || folders.isLoading,
error: feeds.error ?? folders.error,
onRefresh: bloc.refresh,
onRefresh: () async => bloc.refresh(),
itemCount: sorted.length,
itemBuilder: (final context, final index) => _buildFolder(
context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class NotesCategoriesView extends StatelessWidget {
scrollKey: 'notes-categories',
isLoading: notes.isLoading,
error: notes.error,
onRefresh: bloc.refresh,
onRefresh: () async => bloc.refresh(),
itemCount: sorted.length,
itemBuilder: (final context, final index) => _buildCategory(
context,
Expand Down
2 changes: 1 addition & 1 deletion packages/neon/neon_notes/lib/src/widgets/notes_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class NotesView extends StatelessWidget {
scrollKey: 'notes-notes',
isLoading: notesList.isLoading,
error: notesList.error,
onRefresh: bloc.refresh,
onRefresh: () async => bloc.refresh(),
itemCount: sorted.length,
itemBuilder: (final context, final index) => _buildNote(context, sorted[index]),
),
Expand Down
2 changes: 1 addition & 1 deletion packages/neon/neon_notifications/lib/src/pages/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class _NotificationsMainPageState extends State<NotificationsMainPage> {
scrollKey: 'notifications-notifications',
isLoading: notifications.isLoading,
error: notifications.error,
onRefresh: bloc.refresh,
onRefresh: () async => bloc.refresh(),
itemCount: notifications.data?.length,
itemBuilder: (final context, final index) => _buildNotification(context, notifications.data![index]),
),
Expand Down
2 changes: 1 addition & 1 deletion packages/neon_framework/lib/src/bloc/bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ abstract class InteractiveBloc extends Bloc {
/// Refreshes the state of the bloc.
///
/// Commonly involves re-fetching data from the server.
Future<void> refresh();
FutureOr<void> refresh();

/// Adds an error to the [errors] state.
@protected
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:meta/meta.dart';
import 'package:neon_framework/l10n/localizations.dart';
Expand Down Expand Up @@ -90,13 +88,13 @@ class _LoginCheckAccountPageState extends State<LoginCheckAccountPage> {

const HomeRoute().go(context);
}
: () {
: () async {
if (state.hasError && NeonError.getDetails(state.error).isUnauthorized) {
Navigator.pop(context);
return;
}

unawaited(bloc.refresh());
bloc.refresh();
},
child: Text(
state.hasData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class NeonUnifiedSearchResults extends StatelessWidget {
scrollKey: 'unified-search',
isLoading: results.isLoading,
error: results.error,
onRefresh: bloc.refresh,
onRefresh: () async => bloc.refresh(),
itemCount: values?.length ?? 0,
itemBuilder: (final context, final index) {
final snapshot = values![index];
Expand Down

0 comments on commit 0cd0bc2

Please sign in to comment.