From 46d29f21b9a31a12bda598af4fb839385047b807 Mon Sep 17 00:00:00 2001 From: Dat PHAM HOANG Date: Thu, 11 Jan 2024 11:21:23 +0700 Subject: [PATCH] [Android][Disable work manager] Change the logic of network status base on internet connection (update every 5 secs) (cherry picked from commit d665abc45d752165e3c13ef29619fd28b30d8eeb) --- .../presentation/network_connection_controller.dart | 3 +-- .../presentation/sending_queue_controller.dart | 5 ----- .../presentation/sending_queue_view.dart | 1 - .../widgets/bottom_bar_sending_queue_widget.dart | 11 +++++------ lib/l10n/intl_en.arb | 2 +- 5 files changed, 7 insertions(+), 15 deletions(-) diff --git a/lib/features/network_connection/presentation/network_connection_controller.dart b/lib/features/network_connection/presentation/network_connection_controller.dart index 8afc917d1..818194f10 100644 --- a/lib/features/network_connection/presentation/network_connection_controller.dart +++ b/lib/features/network_connection/presentation/network_connection_controller.dart @@ -93,8 +93,7 @@ class NetworkConnectionController extends GetxController { } bool isNetworkConnectionAvailable() { - return _connectivityResult.value != ConnectivityResult.none && - _internetConnectionStatus.value == InternetConnectionStatus.connected; + return _internetConnectionStatus.value == InternetConnectionStatus.connected; } Future hasInternetConnection() { diff --git a/lib/features/sending_queue/presentation/sending_queue_controller.dart b/lib/features/sending_queue/presentation/sending_queue_controller.dart index ad5ee978e..9ed699ed1 100644 --- a/lib/features/sending_queue/presentation/sending_queue_controller.dart +++ b/lib/features/sending_queue/presentation/sending_queue_controller.dart @@ -17,8 +17,6 @@ import 'package:tmail_ui_user/features/email/domain/state/delete_sending_email_s import 'package:tmail_ui_user/features/email/presentation/model/composer_arguments.dart'; import 'package:tmail_ui_user/features/mailbox/domain/model/create_new_mailbox_request.dart'; import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart'; -import 'package:tmail_ui_user/features/network_connection/presentation/network_connection_controller.dart' - if (dart.library.html) 'package:tmail_ui_user/features/network_connection/presentation/web_network_connection_controller.dart'; import 'package:tmail_ui_user/features/offline_mode/model/sending_state.dart'; import 'package:tmail_ui_user/features/sending_queue/domain/extensions/list_sending_email_extension.dart'; import 'package:tmail_ui_user/features/sending_queue/domain/extensions/sending_email_extension.dart'; @@ -46,7 +44,6 @@ class SendingQueueController extends BaseController with MessageDialogActionMixi final GetStoredSendingEmailInteractor _getStoredSendingEmailInteractor; final dashboardController = Get.find(); - final _networkConnectionController = Get.find(); final _sendingQueueIsolateManager = getBinding(); final listSendingEmailController = ScrollController(); @@ -160,8 +157,6 @@ class SendingQueueController extends BaseController with MessageDialogActionMixi bool get isAllUnSelected => dashboardController.listSendingEmails.isAllUnSelected(); - bool get isConnectedNetwork => _networkConnectionController.isNetworkConnectionAvailable() == true; - void refreshSendingQueue() { dashboardController.getAllSendingEmails(); } diff --git a/lib/features/sending_queue/presentation/sending_queue_view.dart b/lib/features/sending_queue/presentation/sending_queue_view.dart index 2e432e9b0..5a7e06b0d 100644 --- a/lib/features/sending_queue/presentation/sending_queue_view.dart +++ b/lib/features/sending_queue/presentation/sending_queue_view.dart @@ -42,7 +42,6 @@ class SendingQueueView extends GetWidget with AppLoaderM } else { return BottomBarSendingQueueWidget( listSendingEmailSelected: controller.dashboardController.listSendingEmails.listSelected(), - isConnectedNetwork: controller.isConnectedNetwork, onHandleSendingEmailActionType: (actionType, listSendingEmails) => controller.handleSendingEmailActionType(context, actionType, listSendingEmails), ); } diff --git a/lib/features/sending_queue/presentation/widgets/bottom_bar_sending_queue_widget.dart b/lib/features/sending_queue/presentation/widgets/bottom_bar_sending_queue_widget.dart index 4f5ee1353..9001e62ea 100644 --- a/lib/features/sending_queue/presentation/widgets/bottom_bar_sending_queue_widget.dart +++ b/lib/features/sending_queue/presentation/widgets/bottom_bar_sending_queue_widget.dart @@ -16,7 +16,6 @@ class BottomBarSendingQueueWidget extends StatelessWidget { final List listSendingEmailSelected; final OnHandleSendingEmailActionType? onHandleSendingEmailActionType; - final bool isConnectedNetwork; final _imagePaths = Get.find(); final _responsiveUtils = Get.find(); @@ -24,8 +23,7 @@ class BottomBarSendingQueueWidget extends StatelessWidget { BottomBarSendingQueueWidget({ super.key, required this.listSendingEmailSelected, - this.onHandleSendingEmailActionType, - this.isConnectedNetwork = true + this.onHandleSendingEmailActionType }); @override @@ -116,9 +114,10 @@ class BottomBarSendingQueueWidget extends StatelessWidget { bool get _canResend { if (PlatformInfo.isMobile) { - return isConnectedNetwork && - listSendingEmailSelected.length == 1 && - (listSendingEmailSelected.first.isWaiting || listSendingEmailSelected.first.isError); + return listSendingEmailSelected.length == 1 && + (listSendingEmailSelected.first.isWaiting || + listSendingEmailSelected.first.isError || + listSendingEmailSelected.first.isCanceled); } else { return false; } diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index a49d4d819..8264933c0 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -2735,7 +2735,7 @@ "placeholders_order": [], "placeholders": {} }, - "messageHasBeenSavedToTheSendingQueue": "Message has been saved to the sending queue.", + "messageHasBeenSavedToTheSendingQueue": "Temporary network issue. Messages queued for retry when connected.", "@messageHasBeenSavedToTheSendingQueue": { "type": "text", "placeholders_order": [],