diff --git a/docs/adr/0033-disable-work-manager-in-sending-email-automatically.md b/docs/adr/0033-disable-work-manager-in-sending-email-automatically.md new file mode 100644 index 0000000000..572c21260a --- /dev/null +++ b/docs/adr/0033-disable-work-manager-in-sending-email-automatically.md @@ -0,0 +1,28 @@ +# 33. Disable work manager in sending email automatically + +Date: 2024-01-12 + +## Status + +Accepted + +## Context + +- In some Wifi environments, network connection status not return the right value +- We can not manage the schedule of sending email well (it depends on the Android scheduler) + +## Decision + +- Disable work manager in sending email automatically +- The status of network in be check directly with `InternetConnectionChecker.hasConnection` +```dart + Future hasInternetConnection() { + return _internetConnectionChecker.hasConnection; + } +``` + +## Consequences + +- If user send message when network is not available, message will be cached and then +- User can resend message manually when network is available +- User can edit/delete cached messages diff --git a/lib/features/caching/caching_manager.dart b/lib/features/caching/caching_manager.dart index 5582feaee5..41726f45e5 100644 --- a/lib/features/caching/caching_manager.dart +++ b/lib/features/caching/caching_manager.dart @@ -18,7 +18,6 @@ import 'package:tmail_ui_user/features/caching/config/hive_cache_config.dart'; import 'package:tmail_ui_user/features/caching/utils/caching_constants.dart'; import 'package:tmail_ui_user/features/mailbox/data/model/state_type.dart'; import 'package:tmail_ui_user/features/mailbox_dashboard/data/local/local_spam_report_manager.dart'; -import 'package:tmail_ui_user/features/offline_mode/controller/work_manager_controller.dart'; import 'package:tmail_ui_user/features/offline_mode/manager/sending_email_cache_manager.dart'; import 'package:tmail_ui_user/features/push_notification/data/keychain/keychain_sharing_manager.dart'; @@ -72,7 +71,7 @@ class CachingManager { _sessionHiveCacheClient.clearAllData(), _newEmailHiveCacheClient.clearAllData(), _openedEmailHiveCacheClient.clearAllData(), - _clearSendingEmailCache(), + _sendingEmailCacheManager.clearAllSendingEmails(), ], if (PlatformInfo.isIOS) _keychainSharingManager.delete() @@ -92,7 +91,7 @@ class CachingManager { ...[ _newEmailHiveCacheClient.clearAllData(), _openedEmailHiveCacheClient.clearAllData(), - _clearSendingEmailCache(), + _sendingEmailCacheManager.clearAllSendingEmails(), ] ], eagerError: true); } @@ -139,12 +138,4 @@ class CachingManager { _fileUtils.removeFolder(CachingConstants.openedEmailContentFolderName), ]); } - - Future _clearSendingEmailCache() async { - final listSendingEmails = await _sendingEmailCacheManager.getAllSendingEmails(); - final sendingIds = listSendingEmails.map((sendingEmail) => sendingEmail.sendingId).toSet().toList(); - if (sendingIds.isNotEmpty) { - await _sendingEmailCacheManager.clearAllSendingEmails(); - } - } } diff --git a/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart b/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart index 1289ea78b9..db3b2b958c 100644 --- a/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart +++ b/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart @@ -109,10 +109,6 @@ import 'package:tmail_ui_user/features/manage_account/presentation/model/account import 'package:tmail_ui_user/features/manage_account/presentation/model/manage_account_arguments.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/config/work_manager_constants.dart'; -import 'package:tmail_ui_user/features/offline_mode/controller/work_manager_controller.dart'; -import 'package:tmail_ui_user/features/offline_mode/work_manager/one_time_work_request.dart'; -import 'package:tmail_ui_user/features/offline_mode/work_manager/worker_type.dart'; import 'package:tmail_ui_user/features/push_notification/domain/state/get_email_state_to_refresh_state.dart'; import 'package:tmail_ui_user/features/push_notification/domain/state/get_mailbox_state_to_refresh_state.dart'; import 'package:tmail_ui_user/features/push_notification/domain/usecases/delete_email_state_to_refresh_interactor.dart'; @@ -155,7 +151,6 @@ import 'package:tmail_ui_user/main/routes/route_navigation.dart'; import 'package:tmail_ui_user/main/routes/route_utils.dart'; import 'package:tmail_ui_user/main/utils/email_receive_manager.dart'; import 'package:uuid/uuid.dart'; -import 'package:workmanager/workmanager.dart' as work_manager; class MailboxDashBoardController extends ReloadableController { diff --git a/lib/features/manage_account/presentation/mailbox_visibility/mailbox_visibility_view.dart b/lib/features/manage_account/presentation/mailbox_visibility/mailbox_visibility_view.dart index 0caa15c664..e7a49f215c 100644 --- a/lib/features/manage_account/presentation/mailbox_visibility/mailbox_visibility_view.dart +++ b/lib/features/manage_account/presentation/mailbox_visibility/mailbox_visibility_view.dart @@ -106,7 +106,7 @@ class MailboxVisibilityView extends GetWidget categories, controller, toggleMailboxCategories: controller.toggleMailboxCategories, - padding: EdgeInsetsDirectional.symmetric(vertical: 8) + padding: const EdgeInsetsDirectional.symmetric(vertical: 8) ), AnimatedContainer( duration: const Duration(milliseconds: 400), diff --git a/lib/main.dart b/lib/main.dart index 380a9f69c4..047ec02ed3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,11 +1,9 @@ import 'package:core/presentation/utils/theme_utils.dart'; import 'package:core/utils/app_logger.dart'; -import 'package:core/utils/platform_info.dart'; import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:get/get.dart'; import 'package:tmail_ui_user/features/caching/config/hive_cache_config.dart'; -import 'package:tmail_ui_user/features/offline_mode/config/work_manager_config.dart'; import 'package:tmail_ui_user/main/bindings/main_bindings.dart'; import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; import 'package:tmail_ui_user/main/localizations/app_localizations_delegate.dart';