From eaaebf56e33ef3ab0ea8bb109d40a1214e48e146 Mon Sep 17 00:00:00 2001 From: Jacob Michalskie Date: Wed, 10 Jan 2024 15:45:06 +0100 Subject: [PATCH] Update riverpod to the latest version --- lib/background/actions/calendar_action_handler.dart | 2 +- lib/background/main_background.dart | 2 +- lib/domain/api/appstore/appstore.dart | 4 ++-- lib/domain/api/auth/auth.dart | 2 +- lib/domain/api/boot/boot.dart | 4 ++-- lib/domain/calendar/calendar_list.dart | 4 ++-- lib/domain/calendar/calendar_syncer.db.dart | 2 +- lib/domain/timeline/watch_timeline_syncer.dart | 2 +- lib/infrastructure/backgroundcomm/BackgroundRpc.dart | 4 ++-- lib/infrastructure/datasources/workarounds.dart | 2 +- lib/ui/devoptions/debug_options_page.dart | 6 +++--- lib/ui/home/tabs/test_tab.dart | 4 ++-- lib/ui/screens/alerting_app_details.dart | 8 ++++---- lib/ui/screens/alerting_apps.dart | 2 +- lib/ui/screens/calendar.dart | 8 ++++---- lib/ui/screens/notifications.dart | 12 ++++++------ lib/ui/setup/boot/rebble_setup_fail.dart | 2 +- lib/ui/setup/pair_page.dart | 4 ++-- lib/ui/splash/splash_page.dart | 4 ++-- pubspec.lock | 12 ++++++------ pubspec.yaml | 2 +- 21 files changed, 46 insertions(+), 46 deletions(-) diff --git a/lib/background/actions/calendar_action_handler.dart b/lib/background/actions/calendar_action_handler.dart index f4f17618..e7e1473d 100644 --- a/lib/background/actions/calendar_action_handler.dart +++ b/lib/background/actions/calendar_action_handler.dart @@ -80,7 +80,7 @@ class CalendarActionHandler implements ActionHandler { final calendarList = await (_calendarList.streamWithExistingValue.firstSuccessOrError() as FutureOr>>); - final calendars = calendarList.data?.value; + final calendars = calendarList.value; if (calendars == null) { return TimelineActionResponse(false); } diff --git a/lib/background/main_background.dart b/lib/background/main_background.dart index e1a96254..565932fb 100644 --- a/lib/background/main_background.dart +++ b/lib/background/main_background.dart @@ -65,7 +65,7 @@ class BackgroundReceiver implements TimelineCallbacks { final asyncValue = await container.readUntilFirstSuccessOrError(preferencesProvider); - return asyncValue.data!.value; + return asyncValue.value!; }); TimelineCallbacks.setup(this); diff --git a/lib/domain/api/appstore/appstore.dart b/lib/domain/api/appstore/appstore.dart index 5bcbc0a4..16c37841 100644 --- a/lib/domain/api/appstore/appstore.dart +++ b/lib/domain/api/appstore/appstore.dart @@ -8,11 +8,11 @@ import 'package:cobble/infrastructure/datasources/web_services/appstore.dart'; final appstoreServiceProvider = FutureProvider((ref) async { final boot = await (await ref.watch(bootServiceProvider.future)).config; - final token = await (await ref.watch(tokenProvider.last)); + final token = await (await ref.watch(tokenProvider.future)); final oauth = await ref.watch(oauthClientProvider.future); final prefs = await ref.watch(preferencesProvider.future); if (token == null) { throw NoTokenException("Service requires a token but none was found in storage"); } return AppstoreService(boot.appstore.base, prefs, oauth, token); -}); \ No newline at end of file +}); diff --git a/lib/domain/api/auth/auth.dart b/lib/domain/api/auth/auth.dart index f3cdc23a..b23a9c49 100644 --- a/lib/domain/api/auth/auth.dart +++ b/lib/domain/api/auth/auth.dart @@ -9,7 +9,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; final authServiceProvider = FutureProvider((ref) async { final boot = await (await ref.watch(bootServiceProvider.future)).config; - final token = await (await ref.watch(tokenProvider.last)); + final token = await (await ref.watch(tokenProvider.future)); final oauth = await ref.watch(oauthClientProvider.future); final prefs = await ref.watch(preferencesProvider.future); if (token == null) { diff --git a/lib/domain/api/boot/boot.dart b/lib/domain/api/boot/boot.dart index d7907c2a..c5cf453f 100644 --- a/lib/domain/api/boot/boot.dart +++ b/lib/domain/api/boot/boot.dart @@ -3,5 +3,5 @@ import 'package:cobble/infrastructure/datasources/web_services/boot.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; final bootServiceProvider = FutureProvider( - (ref) async => BootService(await ref.watch(bootUrlProvider.last) ?? ""), -); \ No newline at end of file + (ref) async => BootService(await ref.watch(bootUrlProvider.future) ?? ""), +); diff --git a/lib/domain/calendar/calendar_list.dart b/lib/domain/calendar/calendar_list.dart index 12245faa..c51c8f1b 100644 --- a/lib/domain/calendar/calendar_list.dart +++ b/lib/domain/calendar/calendar_list.dart @@ -32,7 +32,7 @@ class CalendarList extends StateNotifier>> { await _permissionCheck.hasCalendarPermission(); if (hasCalendarPermission.value == false) { - return AsyncValue.error([ResultError(0, "No permission")]); + return AsyncValue.error([ResultError(0, "No permission")], StackTrace.current); } final preferences = await _preferencesFuture; @@ -43,7 +43,7 @@ class CalendarList extends StateNotifier>> { final calendars = await _deviceCalendarPlugin.retrieveCalendars(); if (!calendars.isSuccess) { - return AsyncValue.error(calendars.errors); + return AsyncValue.error(calendars.errors, StackTrace.current); } else { return AsyncValue.data(calendars.data ?.map((c) => SelectableCalendar( diff --git a/lib/domain/calendar/calendar_syncer.db.dart b/lib/domain/calendar/calendar_syncer.db.dart index a4ab02a7..9447bdcc 100644 --- a/lib/domain/calendar/calendar_syncer.db.dart +++ b/lib/domain/calendar/calendar_syncer.db.dart @@ -33,7 +33,7 @@ class CalendarSyncer { return false; } - final allCalendars = allCalendarsResult.data!.value; + final allCalendars = allCalendarsResult.value!; final now = _dateTimeProvider(); // 1 day is added since we need to get the start of the next day diff --git a/lib/domain/timeline/watch_timeline_syncer.dart b/lib/domain/timeline/watch_timeline_syncer.dart index e1ab11d0..900a0efe 100644 --- a/lib/domain/timeline/watch_timeline_syncer.dart +++ b/lib/domain/timeline/watch_timeline_syncer.dart @@ -134,7 +134,7 @@ class WatchTimelineSyncer { return; } - final plugin = pluginValue.data!.value; + final plugin = pluginValue.value!; const AndroidNotificationDetails androidPlatformChannelSpecifics = AndroidNotificationDetails("WARNINGS", "Warnings", diff --git a/lib/infrastructure/backgroundcomm/BackgroundRpc.dart b/lib/infrastructure/backgroundcomm/BackgroundRpc.dart index 3dbb53c9..9cc53c69 100644 --- a/lib/infrastructure/backgroundcomm/BackgroundRpc.dart +++ b/lib/infrastructure/backgroundcomm/BackgroundRpc.dart @@ -71,10 +71,10 @@ class BackgroundRpc { } else if (receivedMessage.errorResult != null) { result = AsyncValue.error( receivedMessage.errorResult!, - stackTrace: receivedMessage.errorStacktrace, + receivedMessage.errorStacktrace ?? StackTrace.current, ); } else { - result = AsyncValue.error("Received result without any data."); + result = AsyncValue.error("Received result without any data.", StackTrace.current); } waitingCompleter.complete(result); diff --git a/lib/infrastructure/datasources/workarounds.dart b/lib/infrastructure/datasources/workarounds.dart index 44bb75ea..f0059828 100644 --- a/lib/infrastructure/datasources/workarounds.dart +++ b/lib/infrastructure/datasources/workarounds.dart @@ -17,7 +17,7 @@ final neededWorkaroundsProvider = StreamProvider>((ref) { return Stream>.empty(); } - final preferences = preferencesData.data!.value; + final preferences = preferencesData.value!; fetchControls() async { final workaroundControl = WorkaroundsControl(); diff --git a/lib/ui/devoptions/debug_options_page.dart b/lib/ui/devoptions/debug_options_page.dart index e8d75a0a..1f4aa5f0 100644 --- a/lib/ui/devoptions/debug_options_page.dart +++ b/lib/ui/devoptions/debug_options_page.dart @@ -11,11 +11,11 @@ class DebugOptionsPage extends HookConsumerWidget implements CobbleScreen { @override Widget build(BuildContext context, WidgetRef ref) { final preferences = ref.watch(preferencesProvider); - final bootUrl = ref.watch(bootUrlProvider).data?.value ?? ""; + final bootUrl = ref.watch(bootUrlProvider).value ?? ""; final shouldOverrideBoot = - ref.watch(shouldOverrideBootProvider).data?.value ?? false; + ref.watch(shouldOverrideBootProvider).value ?? false; final overrideBootUrl = - ref.watch(overrideBootValueProvider).data?.value ?? ""; + ref.watch(overrideBootValueProvider).value ?? ""; final bootUrlController = useTextEditingController(); final bootOverrideUrlController = useTextEditingController(); diff --git a/lib/ui/home/tabs/test_tab.dart b/lib/ui/home/tabs/test_tab.dart index 9e25005e..25608ab9 100644 --- a/lib/ui/home/tabs/test_tab.dart +++ b/lib/ui/home/tabs/test_tab.dart @@ -121,8 +121,8 @@ class TestTab extends HookConsumerWidget implements CobbleScreen { Switch( value: workaround.disabled, onChanged: (value) async { - await preferences.data?.value - .setWorkaroundDisabled(workaround.name, value); + await preferences.value + ?.setWorkaroundDisabled(workaround.name, value); }, ), Text(workaround.name) diff --git a/lib/ui/screens/alerting_app_details.dart b/lib/ui/screens/alerting_app_details.dart index 0f5cf428..60fec355 100644 --- a/lib/ui/screens/alerting_app_details.dart +++ b/lib/ui/screens/alerting_app_details.dart @@ -51,7 +51,7 @@ class AlertingAppDetails extends HookConsumerWidget implements CobbleScreen { child: Switch( value: app.enabled, onChanged: (value) async { - var mutedPkgList = mutedPackages.data?.value ?? []; + var mutedPkgList = mutedPackages.value ?? []; if (value) { mutedPkgList.removeWhere((element) => element == app.packageId); }else { @@ -59,8 +59,8 @@ class AlertingAppDetails extends HookConsumerWidget implements CobbleScreen { mutedPkgList.add(app.packageId); } app = AlertingApp(app.name, value, app.packageId); - await preferences.data?.value - .setNotificationsMutedPackages(mutedPkgList); + await preferences.value + ?.setNotificationsMutedPackages(mutedPkgList); }, ), ), @@ -101,4 +101,4 @@ class AlertingAppDetails extends HookConsumerWidget implements CobbleScreen { ); } -} \ No newline at end of file +} diff --git a/lib/ui/screens/alerting_apps.dart b/lib/ui/screens/alerting_apps.dart index 4edeae0f..3dcde248 100644 --- a/lib/ui/screens/alerting_apps.dart +++ b/lib/ui/screens/alerting_apps.dart @@ -79,7 +79,7 @@ class AlertingApps extends HookConsumerWidget implements CobbleScreen { if (snapshot.hasData && snapshot.data != null) { List apps = []; for (int i = 0; i < snapshot.data!.packageId!.length; i++) { - final enabled = (mutedPackages.data?.value ?? []).firstWhere( + final enabled = (mutedPackages.value ?? []).firstWhere( (element) => element == snapshot.data!.packageId![i], orElse: () => null) == null; diff --git a/lib/ui/screens/calendar.dart b/lib/ui/screens/calendar.dart index 2185ccc7..570e79cf 100644 --- a/lib/ui/screens/calendar.dart +++ b/lib/ui/screens/calendar.dart @@ -46,9 +46,9 @@ class Calendar extends HookConsumerWidget implements CobbleScreen { title: tr.calendar.toggleTitle, subtitle: tr.calendar.toggleSubtitle, child: Switch( - value: calendarSyncEnabled.data?.value ?? false, + value: calendarSyncEnabled.value ?? false, onChanged: (value) async { - await preferences.data?.value.setCalendarSyncEnabled(value); + await preferences.value?.setCalendarSyncEnabled(value); if (!value) { backgroundRpc.triggerMethod(DeleteAllCalendarPinsRequest()); @@ -57,11 +57,11 @@ class Calendar extends HookConsumerWidget implements CobbleScreen { ), ), CobbleDivider(), - if (calendarSyncEnabled.data?.value ?? false) ...[ + if (calendarSyncEnabled.value ?? false) ...[ CobbleTile.title( title: tr.calendar.choose, ), - ...calendars.data?.value.map((e) { + ...calendars.value?.map((e) { return CobbleTile.setting( leading: BoxDecoration( color: Color(e.color).withOpacity(1), diff --git a/lib/ui/screens/notifications.dart b/lib/ui/screens/notifications.dart index 2ba6c32a..0f8107ae 100644 --- a/lib/ui/screens/notifications.dart +++ b/lib/ui/screens/notifications.dart @@ -28,9 +28,9 @@ class Notifications extends HookConsumerWidget implements CobbleScreen { leading: RebbleIcons.notification, title: tr.notifications.enabled, child: Switch( - value: notifcationsEnabled.data?.value ?? true, + value: notifcationsEnabled.value ?? true, onChanged: (bool value) async { - await preferences.data?.value.setNotificationsEnabled(value); + await preferences.value?.setNotificationsEnabled(value); }, ), ), @@ -55,9 +55,9 @@ class Notifications extends HookConsumerWidget implements CobbleScreen { leading: CobbleTile.reservedIconSpace, title: tr.notifications.silence.notifications, child: Switch( - value: phoneNotificationsMuteEnabled.data?.value ?? false, + value: phoneNotificationsMuteEnabled.value ?? false, onChanged: (bool value) async { - await preferences.data?.value.setPhoneNotificationMute(value); + await preferences.value?.setPhoneNotificationMute(value); }, ), ), @@ -65,9 +65,9 @@ class Notifications extends HookConsumerWidget implements CobbleScreen { leading: CobbleTile.reservedIconSpace, title: tr.notifications.silence.calls, child: Switch( - value: phoneCallsMuteEnabled.data?.value ?? false, + value: phoneCallsMuteEnabled.value ?? false, onChanged: (bool value) async { - await preferences.data?.value.setPhoneCallsMute(value); + await preferences.value?.setPhoneCallsMute(value); }, ), ), diff --git a/lib/ui/setup/boot/rebble_setup_fail.dart b/lib/ui/setup/boot/rebble_setup_fail.dart index fccc4902..cf7747f3 100644 --- a/lib/ui/setup/boot/rebble_setup_fail.dart +++ b/lib/ui/setup/boot/rebble_setup_fail.dart @@ -26,7 +26,7 @@ class RebbleSetupFail extends HookConsumerWidget implements CobbleScreen { ), floatingActionButton: FloatingActionButton.extended( onPressed: () async { - await preferences.data?.value.setWasSetupSuccessful(false); + await preferences.value?.setWasSetupSuccessful(false); context.pushAndRemoveAllBelow(HomePage()); }, label: Text(tr.setup.failure.fab)), diff --git a/lib/ui/setup/pair_page.dart b/lib/ui/setup/pair_page.dart index 823b0068..f25858af 100644 --- a/lib/ui/setup/pair_page.dart +++ b/lib/ui/setup/pair_page.dart @@ -51,7 +51,7 @@ class PairPage extends HookConsumerWidget implements CobbleScreen { Widget build(BuildContext context, WidgetRef ref) { final pairedStorage = ref.watch(pairedStorageProvider.notifier); final scan = ref.watch(scanProvider); - final pair = ref.watch(pairProvider).data?.value; + final pair = ref.watch(pairProvider).value; final preferences = ref.watch(preferencesProvider); useEffect(() { @@ -99,7 +99,7 @@ class PairPage extends HookConsumerWidget implements CobbleScreen { StringWrapper addressWrapper = StringWrapper(); addressWrapper.value = dev.address; uiConnectionControl.connectToWatch(addressWrapper); - preferences.data?.value.setHasBeenConnected(); + preferences.value?.setHasBeenConnected(); }; final title = tr.pairPage.title; diff --git a/lib/ui/splash/splash_page.dart b/lib/ui/splash/splash_page.dart index 5b71fee2..a50ca64f 100644 --- a/lib/ui/splash/splash_page.dart +++ b/lib/ui/splash/splash_page.dart @@ -24,12 +24,12 @@ class SplashPage extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - final hasBeenConnected = ref.watch(hasBeenConnectedProvider).data; + final hasBeenConnected = ref.watch(hasBeenConnectedProvider).value; // Let's not do a timed splash screen here, it's a waste of // the user's time and there are better platform ways to do it useEffect(() { if (hasBeenConnected != null) { - Future.microtask(_openHome(hasBeenConnected.value, context: context)); + Future.microtask(_openHome(hasBeenConnected, context: context)); } }, [hasBeenConnected]); return CobbleScaffold.page( diff --git a/pubspec.lock b/pubspec.lock index 30549676..a1310ea6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -359,10 +359,10 @@ packages: dependency: transitive description: name: flutter_riverpod - sha256: d84e180f039a6b963e610d2e4435641fdfe8f12437e8770e963632e05af16d80 + sha256: b6cb0041c6c11cefb2dcb97ef436eba43c6d41287ac6d8ca93e02a497f53a4f3 url: "https://pub.dev" source: hosted - version: "1.0.4" + version: "2.3.7" flutter_secure_storage: dependency: "direct main" description: @@ -473,10 +473,10 @@ packages: dependency: "direct main" description: name: hooks_riverpod - sha256: c2264035396e5fc238e98ef053b07b9cab298450e39c6a8704634c8452c61bbe + sha256: "2bb8ae6a729e1334f71f1ef68dd5f0400dca8f01de8cbdcde062584a68017b18" url: "https://pub.dev" source: hosted - version: "1.0.4" + version: "2.3.8" http: dependency: transitive description: @@ -817,10 +817,10 @@ packages: dependency: transitive description: name: riverpod - sha256: e7f097159b9512f5953ff544164c19057f45ce28fd0cb971fc4cad1f7b28217d + sha256: b0657b5b30c81a3184bdaab353045f0a403ebd60bb381591a8b7ad77dcade793 url: "https://pub.dev" source: hosted - version: "1.0.3" + version: "2.3.7" rxdart: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index f377fa9f..3302d63a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -35,7 +35,7 @@ dependencies: sqflite: ^2.2.0 package_info_plus: ^3.0.0 state_notifier: ^0.7.0 - hooks_riverpod: ^1.0.1 + hooks_riverpod: ^2.0.0 flutter_hooks: ^0.18.0 device_calendar: ^4.3.0 uuid_type: ^2.0.0