diff --git a/mih_ui/lib/mih_hive/mzansi_profile_hive_data.dart b/mih_ui/lib/mih_hive/mzansi_profile_hive_data.dart index 8ecccf12..cd818fff 100644 --- a/mih_ui/lib/mih_hive/mzansi_profile_hive_data.dart +++ b/mih_ui/lib/mih_hive/mzansi_profile_hive_data.dart @@ -1,5 +1,3 @@ -import 'dart:math'; - import 'package:hive_ce_flutter/hive_ce_flutter.dart'; import 'package:ken_logger/ken_logger.dart'; import 'package:mzansi_innovation_hub/mih_objects/app_user.dart'; @@ -130,7 +128,7 @@ class MzansiProfileHiveData { } // Sync Local Data from data from MIH Server - Future syncProfileDataWithServer() async { + Future syncProfileDataWithServer() async { try { AppUser? remoteUser = await MihUserServices().getMyUserDetailsV2(); if (remoteUser != null) { @@ -159,8 +157,10 @@ class MzansiProfileHiveData { remoteBusiness.business_id); cacheBusinessProfileLinksData(remoteBusinessLinks); } + return true; } catch (error) { - KenLogger.warning("App operating offline mode. Sync paused"); + KenLogger.warning("App Operating in Offline Mode. Sync Paused"); + return false; // KenLogger.warning("App operating offline mode. Sync paused: $error"); } } diff --git a/mih_ui/lib/mih_packages/mih_home/mih_home.dart b/mih_ui/lib/mih_packages/mih_home/mih_home.dart index ebc2478b..cd29c124 100644 --- a/mih_ui/lib/mih_packages/mih_home/mih_home.dart +++ b/mih_ui/lib/mih_packages/mih_home/mih_home.dart @@ -88,11 +88,17 @@ class _MihHomeState extends State { RefreshIndicator( key: mzansiProfileProvider.refreshIndicatorKey, onRefresh: () async { - await mzansiProfileProvider.syncWithMihServerData(); + bool success = + await mzansiProfileProvider.syncWithMihServerData(); if (context.mounted) { ScaffoldMessenger.of(context).showSnackBar( MihSnackBar( - child: Text("Data Synced with MIH Server."), + child: Text( + success + ? "Data Synced with MIH Server." + : "MIH App operation in Offline Mode", + ), + // backgroundColor: success ? null : MihColors.red(), ), ); } diff --git a/mih_ui/lib/mih_providers/mzansi_profile_provider.dart b/mih_ui/lib/mih_providers/mzansi_profile_provider.dart index 81ff4977..9e2c7455 100644 --- a/mih_ui/lib/mih_providers/mzansi_profile_provider.dart +++ b/mih_ui/lib/mih_providers/mzansi_profile_provider.dart @@ -72,9 +72,10 @@ class MzansiProfileProvider extends ChangeNotifier { notifyListeners(); } - Future syncWithMihServerData() async { - await _hiveData.syncProfileDataWithServer(); + Future syncWithMihServerData() async { + bool success = await _hiveData.syncProfileDataWithServer(); loadCachedProfileState(); + return success; } void triggerRefresh() {