From 0ab955b2dace62c1ba8379a556e27d0f9b292626 Mon Sep 17 00:00:00 2001 From: poka Date: Thu, 22 Dec 2022 23:53:12 +0100 Subject: [PATCH] GPT fixed this issue (fake offline detection): https://git.duniter.org/clients/gecko/-/issues/21 --- lib/providers/home.dart | 5 ----- lib/screens/home.dart | 12 +++++++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/providers/home.dart b/lib/providers/home.dart index 484441e..6535845 100644 --- a/lib/providers/home.dart +++ b/lib/providers/home.dart @@ -119,11 +119,6 @@ class HomeProvider with ChangeNotifier { return list[i]; } - void handleSearchStart() { - isSearching = true; - notifyListeners(); - } - // void playSound(String customSound, double volume) async { // await player.play('$customSound.wav', // volume: volume, mode: PlayerMode.LOW_LATENCY, stayAwake: false); diff --git a/lib/screens/home.dart b/lib/screens/home.dart index 497ba47..d7833c7 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -96,6 +96,8 @@ class _HomeScreenState extends State { // sub.nodeConnected = false; // } + // Améliore ce code car il y a un bug: parfois l'app se croit hors ligne, alors que c'est faux, le téléphone est bien connecté à internet + // (GPT vscode extension fixed it for my...) HomeProvider homeProvider = Provider.of(context, listen: false); Connectivity() @@ -108,9 +110,13 @@ class _HomeScreenState extends State { homeProvider.changeMessage("notConnectedToInternet".tr(), 0); sub.reload(); } else { - await sub.connectNode(context); - // Currency parameters - sub.initCurrencyParameters(); + // Check if the phone is actually connected to the internet + var connectivityResult = await (Connectivity().checkConnectivity()); + if (connectivityResult != ConnectivityResult.none) { + await sub.connectNode(context); + // Currency parameters + await sub.initCurrencyParameters(); + } } // Indexer Blockchain start