diff --git a/lib/app/components/app_update_handler/app_update_handler.dart b/lib/app/components/app_update_handler/app_update_handler.dart index ffc9e048c..bb1b4ce53 100644 --- a/lib/app/components/app_update_handler/app_update_handler.dart +++ b/lib/app/components/app_update_handler/app_update_handler.dart @@ -9,7 +9,8 @@ import 'package:ion/app/router/app_routes.c.dart'; import 'package:ion/app/router/utils/show_simple_bottom_sheet.dart'; class AppUpdateHandler extends HookConsumerWidget { - const AppUpdateHandler({super.key}); + const AppUpdateHandler({required this.child, super.key}); + final Widget child; @override Widget build(BuildContext context, WidgetRef ref) { @@ -27,6 +28,6 @@ class AppUpdateHandler extends HookConsumerWidget { }); } - return const SizedBox.shrink(); + return child; } } diff --git a/lib/app/features/config/providers/config_provider.c.dart b/lib/app/features/config/providers/config_provider.c.dart index 3f7627139..ce3157a70 100644 --- a/lib/app/features/config/providers/config_provider.c.dart +++ b/lib/app/features/config/providers/config_provider.c.dart @@ -2,6 +2,8 @@ import 'dart:io'; +import 'package:dio/dio.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:ion/app/exceptions/exceptions.dart'; import 'package:ion/app/features/core/providers/dio_provider.c.dart'; import 'package:ion/app/features/core/providers/env_provider.c.dart'; @@ -10,9 +12,11 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'config_provider.c.g.dart'; @riverpod -class ConfigNotifier extends _$ConfigNotifier { - @override - FutureOr build() {} +ConfigService configService(Ref ref) => ConfigService(ref.watch(dioProvider)); + +class ConfigService { + ConfigService(this.dio); + final Dio dio; ConfigName _getPlatformConfigName() { if (Platform.isAndroid) { @@ -37,7 +41,7 @@ class ConfigNotifier extends _$ConfigNotifier { final path = '$baseUrl/v1/config/$configName'; try { - final response = await ref.read(dioProvider).get(path); + final response = await dio.get(path); if (response.data == null) { throw ForceUpdateFetchConfigException(); } diff --git a/lib/app/features/config/providers/force_update_provider.c.dart b/lib/app/features/config/providers/force_update_provider.c.dart index 1be899342..4be48c15e 100644 --- a/lib/app/features/config/providers/force_update_provider.c.dart +++ b/lib/app/features/config/providers/force_update_provider.c.dart @@ -48,8 +48,8 @@ class ForceUpdate extends _$ForceUpdate { if (lastSyncDate == null || DateTime.now().difference(lastSyncDate).inMilliseconds >= eightHoursInMilliseconds) { - final remoteVersion = - await ref.read(configNotifierProvider.notifier).fetchConfigForCurrentPlatform(); + final service = ref.read(configServiceProvider); + final remoteVersion = await service.fetchConfigForCurrentPlatform(); final packageInfo = await PackageInfo.fromPlatform(); final localVersion = packageInfo.version; diff --git a/lib/app/router/components/app_router_builder.dart b/lib/app/router/components/app_router_builder.dart index 32e87cc2b..67b1e547e 100644 --- a/lib/app/router/components/app_router_builder.dart +++ b/lib/app/router/components/app_router_builder.dart @@ -35,14 +35,15 @@ class AppRouterBuilder extends HookConsumerWidget { child: SafeArea( top: isShowSafeArea.value, bottom: false, - child: Column( - children: [ - const GlobalNotificationBar(), - Expanded( - child: child ?? const SizedBox.shrink(), - ), - const AppUpdateHandler(), - ], + child: AppUpdateHandler( + child: Column( + children: [ + const GlobalNotificationBar(), + Expanded( + child: child ?? const SizedBox.shrink(), + ), + ], + ), ), ), );