From a0cf2a640e855b595a2e1663c42a77f499a53c99 Mon Sep 17 00:00:00 2001 From: hiddify <114227601+hiddify-com@users.noreply.github.com> Date: Sat, 21 Dec 2024 18:25:09 +0100 Subject: [PATCH] new: add some more checks --- android/app/build.gradle | 2 ++ lib/bootstrap.dart | 1 + lib/core/analytics/analytics_controller.dart | 1 + lib/features/common/adaptive_root_scaffold.dart | 4 ++-- .../connection/notifier/connection_notifier.dart | 7 ++++--- lib/features/home/widget/connection_button.dart | 4 ++-- lib/features/proxy/active/active_proxy_card.dart | 12 +++++++++--- pubspec.lock | 8 ++++---- pubspec.yaml | 2 +- 9 files changed, 26 insertions(+), 15 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 6a6fc276..9ae3f3d4 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -122,5 +122,7 @@ dependencies { implementation 'androidx.core:core-ktx:1.15.0' implementation 'androidx.appcompat:appcompat:1.7.0' implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.8.7' + implementation "androidx.compose.ui:ui:1.7.6" + } \ No newline at end of file diff --git a/lib/bootstrap.dart b/lib/bootstrap.dart index 67345470..b3d02d49 100644 --- a/lib/bootstrap.dart +++ b/lib/bootstrap.dart @@ -167,6 +167,7 @@ Future lazyBootstrap( if (!kIsWeb) { FlutterNativeSplash.remove(); } + SentryFlutter.setAppStartEnd(DateTime.now().toUtc()); } Future _init( diff --git a/lib/core/analytics/analytics_controller.dart b/lib/core/analytics/analytics_controller.dart index 15ba857a..6118730c 100644 --- a/lib/core/analytics/analytics_controller.dart +++ b/lib/core/analytics/analytics_controller.dart @@ -47,6 +47,7 @@ class AnalyticsController extends _$AnalyticsController with AppLogger { options.debug = kDebugMode; options.enableNativeCrashHandling = true; options.enableNdkScopeSync = true; + options.autoAppStart = false; // options.attachScreenshot = true; options.serverName = ""; options.attachThreads = true; diff --git a/lib/features/common/adaptive_root_scaffold.dart b/lib/features/common/adaptive_root_scaffold.dart index bae1278a..5b4b47b3 100644 --- a/lib/features/common/adaptive_root_scaffold.dart +++ b/lib/features/common/adaptive_root_scaffold.dart @@ -31,8 +31,8 @@ class AdaptiveRootScaffold extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - final t = ref.watch(translationsProvider).requireValue; - + final t = ref.watch(translationsProvider).valueOrNull; + if (t == null) return const SizedBox.shrink(); // final selectedIndex = getCurrentIndex(context); var allnavigationItems = [ NavigationItem( diff --git a/lib/features/connection/notifier/connection_notifier.dart b/lib/features/connection/notifier/connection_notifier.dart index 7d0df1ad..fbcd390d 100644 --- a/lib/features/connection/notifier/connection_notifier.dart +++ b/lib/features/connection/notifier/connection_notifier.dart @@ -80,12 +80,13 @@ class ConnectionNotifier extends _$ConnectionNotifier with AppLogger { await haptic.lightImpact(); await ref.read(Preferences.startedByUser.notifier).update(true); await _connect(); - case Connected(): + // case Connected(): + default: await haptic.mediumImpact(); await ref.read(Preferences.startedByUser.notifier).update(false); await _disconnect(); - default: - loggy.warning("switching status, debounce"); + // default: + // loggy.warning("switching status, debounce"); } } } diff --git a/lib/features/home/widget/connection_button.dart b/lib/features/home/widget/connection_button.dart index 84efa5a2..69d78cfa 100644 --- a/lib/features/home/widget/connection_button.dart +++ b/lib/features/home/widget/connection_button.dart @@ -125,8 +125,8 @@ class ConnectionButton extends HookConsumerWidget { final activeProfile = await ref.read(activeProfileProvider.future); return await ref.read(connectionNotifierProvider.notifier).reconnect(activeProfile); }, - AsyncData(value: Disconnected()) || AsyncError() => () async { - if (ref.read(activeProfileProvider).value == null) { + AsyncData(value: Disconnected()) || AsyncData(value: Connecting()) || AsyncError() => () async { + if (ref.read(activeProfileProvider).valueOrNull == null) { await showDialog( context: context, builder: (context) => PlatformAlertDialog( diff --git a/lib/features/proxy/active/active_proxy_card.dart b/lib/features/proxy/active/active_proxy_card.dart index 460f9cae..fe200708 100644 --- a/lib/features/proxy/active/active_proxy_card.dart +++ b/lib/features/proxy/active/active_proxy_card.dart @@ -8,9 +8,10 @@ import 'package:hiddify/features/proxy/active/active_proxy_notifier.dart'; import 'package:hiddify/features/proxy/active/ip_widget.dart'; import 'package:hiddify/features/proxy/widget/proxy_tile.dart'; import 'package:hiddify/hiddifycore/generated/v2/hcore/hcore.pb.dart'; +import 'package:hiddify/utils/custom_loggers.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -class ActiveProxyFooter extends ConsumerWidget { +class ActiveProxyFooter extends ConsumerWidget with InfraLogger { const ActiveProxyFooter({super.key}); @override @@ -29,8 +30,13 @@ class ActiveProxyFooter extends ConsumerWidget { // Handle URL test in a way that won't trigger during build Future handleUrlTest() async { - if (!context.mounted) return; - await ref.read(activeProxyNotifierProvider.notifier).urlTest(activeProxy.tag); + try { + if (!context.mounted) return; + await ref.read(activeProxyNotifierProvider.notifier).urlTest(activeProxy.tag); + } catch (e) { + // Handle error here + loggy.error("Error during URL test: $e"); + } } // Handle showing proxy info diff --git a/pubspec.lock b/pubspec.lock index d13332ec..1888c721 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1577,10 +1577,10 @@ packages: dependency: transitive description: name: sentry - sha256: "27088acf02728692f1067d6cc5b4ced37894080dc1b6147357f9e2961c6a5c9b" + sha256: b1ead7ca4da0949aed9482c4962f172021a4417f0a126fa974878c2301c16df7 url: "https://pub.dev" source: hosted - version: "8.11.1" + version: "8.11.2" sentry_dart_plugin: dependency: "direct main" description: @@ -1593,10 +1593,10 @@ packages: dependency: "direct main" description: name: sentry_flutter - sha256: "8e416b8549322c643ad4ee5956185d7a429417b68f9ddeb646aa08e319f01201" + sha256: d978861bc413ef98b663b065a65e780b255bfcdc0e2fa307884f7f6df0f1a406 url: "https://pub.dev" source: hosted - version: "8.11.1" + version: "8.11.2" share_plus: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index f31d8313..ff2e3e04 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -51,7 +51,7 @@ dependencies: url_launcher: ^6.2.5 vclibs: ^0.1.2 launch_at_startup: ^0.3.1 - sentry_flutter: ^8.9.0 + sentry_flutter: ^8.11.2 sentry_dart_plugin: ^2.1.0 sqlite3_flutter_libs: ^0.5.25 combine: ^0.5.7