Skip to content

Commit

Permalink
fix: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-hector committed Dec 24, 2024
1 parent 3858775 commit b0ee150
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
5 changes: 3 additions & 2 deletions lib/app/components/app_update_handler/app_update_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -27,6 +28,6 @@ class AppUpdateHandler extends HookConsumerWidget {
});
}

return const SizedBox.shrink();
return child;
}
}
12 changes: 8 additions & 4 deletions lib/app/features/config/providers/config_provider.c.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -10,9 +12,11 @@ import 'package:riverpod_annotation/riverpod_annotation.dart';
part 'config_provider.c.g.dart';

@riverpod
class ConfigNotifier extends _$ConfigNotifier {
@override
FutureOr<void> build() {}
ConfigService configService(Ref ref) => ConfigService(ref.watch(dioProvider));

class ConfigService {
ConfigService(this.dio);
final Dio dio;

ConfigName _getPlatformConfigName() {
if (Platform.isAndroid) {
Expand All @@ -37,7 +41,7 @@ class ConfigNotifier extends _$ConfigNotifier {
final path = '$baseUrl/v1/config/$configName';

try {
final response = await ref.read(dioProvider).get<String>(path);
final response = await dio.get<String>(path);
if (response.data == null) {
throw ForceUpdateFetchConfigException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 9 additions & 8 deletions lib/app/router/components/app_router_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
),
],
),
),
),
);
Expand Down

0 comments on commit b0ee150

Please sign in to comment.