Skip to content

Commit

Permalink
Refactor ref.read usage based on doc
Browse files Browse the repository at this point in the history
  • Loading branch information
r52 committed Jul 15, 2023
1 parent 24fec6f commit 38e39b3
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/local/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class LocalLibrarySettingsWidget extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final nav = Navigator.of(context);
final cfg = ref.read(localConfigProvider);
final cfg = ref.watch(localConfigProvider);
final config = useState(cfg);

return Scaffold(
Expand Down
2 changes: 1 addition & 1 deletion lib/mangadex/creator_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Route createCreatorViewRoute(CreatorType creator) {
Future<Iterable<Manga>> _fetchCreatorTitles(
_FetchCreatorTitlesRef ref, CreatorType creator) async {
final mangas = await ref.watch(creatorTitlesProvider(creator).future);
await ref.read(statisticsProvider.notifier).get(mangas);
await ref.watch(statisticsProvider.notifier).get(mangas);

ref.keepAlive();

Expand Down
2 changes: 1 addition & 1 deletion lib/mangadex/creator_view.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions lib/mangadex/group_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ Future<List<ChapterFeedItemData>> _fetchGroupFeed(

final mangas = await api.fetchManga(ids: mangaIds);

await ref.read(statisticsProvider.notifier).get(mangas);
await ref.watch(statisticsProvider.notifier).get(mangas);

if (loggedin) {
await ref.read(readChaptersProvider.notifier).get(mangas);
await ref.watch(readChaptersProvider.notifier).get(mangas);
}

final mangaMap = Map<String, Manga>.fromIterable(mangas, key: (e) => e.id);
Expand Down Expand Up @@ -71,7 +71,7 @@ Future<List<ChapterFeedItemData>> _fetchGroupFeed(
Future<Iterable<Manga>> _fetchGroupTitles(
_FetchGroupTitlesRef ref, Group group) async {
final mangas = await ref.watch(groupTitlesProvider(group).future);
await ref.read(statisticsProvider.notifier).get(mangas);
await ref.watch(statisticsProvider.notifier).get(mangas);

ref.keepAlive();

Expand Down
4 changes: 2 additions & 2 deletions lib/mangadex/group_view.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/mangadex/library.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class MangaDexLibraryView extends ConsumerWidget {
data: (result) {
return MangaListWidget(
title: Text(
'${ref.read(userLibraryProvider(type).notifier).total()} Mangas',
'${ref.watch(userLibraryProvider(type).notifier).total()} Mangas',
style: const TextStyle(fontSize: 24),
),
physics: const AlwaysScrollableScrollPhysics(),
Expand Down
6 changes: 3 additions & 3 deletions lib/mangadex/manga_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ Future<void> _fetchReadChaptersRedun(
if (loggedin) {
// Redundant retrieve read chapters when opening the manga
// from places where it hasn't been retrieved yet
await ref.read(readChaptersProvider.notifier).get([manga]);
await ref.watch(readChaptersProvider.notifier).get([manga]);

await ref.read(ratingsProvider.notifier).get([manga]);
await ref.watch(ratingsProvider.notifier).get([manga]);
}

await ref.read(statisticsProvider.notifier).get([manga]);
await ref.watch(statisticsProvider.notifier).get([manga]);
}

class MangaDexMangaViewWidget extends HookConsumerWidget {
Expand Down
2 changes: 1 addition & 1 deletion lib/mangadex/manga_view.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/mangadex/search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class MangaDexSearchWidget extends HookConsumerWidget {
},
),
if (!results.isLoading &&
!ref.read(mangaSearchProvider(filter).notifier).isAtEnd())
!ref.watch(mangaSearchProvider(filter).notifier).isAtEnd())
SliverToBoxAdapter(
child: Center(
child: Padding(
Expand Down
2 changes: 1 addition & 1 deletion lib/mangadex/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MangaDexSettingsWidget extends HookConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
final nav = Navigator.of(context);
final bool screenSizeSmall = DeviceContext.screenWidthSmall(context);
final cfg = ref.read(mdConfigProvider);
final cfg = ref.watch(mdConfigProvider);
final config = useState(cfg);

return Scaffold(
Expand Down

0 comments on commit 38e39b3

Please sign in to comment.