TF-3507 Try to avoid screen blink when refreshing email list
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
+5
-3
@@ -1,12 +1,13 @@
|
||||
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:rich_text_composer/views/commons/logger.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/utils/email_utils.dart';
|
||||
import 'package:tmail_ui_user/features/home/data/exceptions/session_exceptions.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/model/search/email_sort_order_type.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/constants/thread_constants.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/email_filter.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/state/clean_and_get_all_email_state.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/state/get_all_email_state.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/model/loading_more_status.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/thread_controller.dart';
|
||||
|
||||
@@ -14,6 +15,8 @@ extension HandlePullToRefreshListEmailExtension on ThreadController {
|
||||
|
||||
Future<void> onRefresh() async {
|
||||
log('HandlePullToRefreshListEmailExtension::onRefresh:Started');
|
||||
consumeState(Stream.value(Right(GetAllEmailLoading())));
|
||||
await Future.delayed(const Duration(milliseconds: 300)); // Create loading effect
|
||||
canLoadMore = false;
|
||||
loadingMoreStatus.value == LoadingMoreStatus.idle;
|
||||
getAllEmailAction();
|
||||
@@ -21,8 +24,7 @@ extension HandlePullToRefreshListEmailExtension on ThreadController {
|
||||
|
||||
Future<void> onCleanAndRefresh() async {
|
||||
log('HandlePullToRefreshListEmailExtension::onCleanAndRefresh:Started');
|
||||
canLoadMore = false;
|
||||
loadingMoreStatus.value == LoadingMoreStatus.idle;
|
||||
resetToOriginalValue();
|
||||
cleanAndGetAllEmailAction();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import 'package:core/data/model/source_type/data_source_type.dart';
|
||||
import 'package:core/utils/file_utils.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_bindings.dart';
|
||||
import 'package:tmail_ui_user/features/caching/caching_manager.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/repository/email_repository.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/datasource/state_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/datasource_impl/state_datasource_impl.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/local/state_cache_manager.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/data/local/fcm_cache_manager.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/datasource/thread_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/datasource_impl/local_thread_datasource_impl.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/datasource_impl/thread_datasource_impl.dart';
|
||||
@@ -56,9 +55,7 @@ class ThreadBindings extends BaseBindings {
|
||||
Get.find<RemoteExceptionThrower>()));
|
||||
Get.lazyPut(() => LocalThreadDataSourceImpl(
|
||||
Get.find<EmailCacheManager>(),
|
||||
Get.find<FCMCacheManager>(),
|
||||
Get.find<StateCacheManager>(),
|
||||
Get.find<FileUtils>(),
|
||||
Get.find<CachingManager>(),
|
||||
Get.find<CacheExceptionThrower>(),
|
||||
));
|
||||
Get.lazyPut(() => StateDataSourceImpl(
|
||||
|
||||
@@ -267,14 +267,14 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
&& mailbox.mailboxId != _currentMemoryMailboxId) {
|
||||
_currentMemoryMailboxId = mailbox.id;
|
||||
consumeState(Stream.value(Right(GetAllEmailLoading())));
|
||||
_resetToOriginalValue();
|
||||
resetToOriginalValue();
|
||||
getAllEmailAction(
|
||||
getLatestChanges: mailboxDashBoardController.isFirstSessionLoad,
|
||||
);
|
||||
mailboxDashBoardController.setIsFirstSessionLoad(false);
|
||||
} else if (mailbox == null) { // disable current mailbox when search active
|
||||
_currentMemoryMailboxId = null;
|
||||
_resetToOriginalValue();
|
||||
resetToOriginalValue();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -468,7 +468,7 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
accountId: _accountId,
|
||||
userName: _session?.username,
|
||||
);
|
||||
_getAllEmailAction();
|
||||
getAllEmailAction();
|
||||
} else if (error is MethodLevelErrors) {
|
||||
if (currentOverlayContext != null && error.message != null) {
|
||||
appToast.showToastErrorMessage(
|
||||
@@ -480,8 +480,8 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
}
|
||||
}
|
||||
|
||||
void _resetToOriginalValue() {
|
||||
log('ThreadController::_resetToOriginalValue');
|
||||
void resetToOriginalValue() {
|
||||
log('ThreadController::resetToOriginalValue');
|
||||
mailboxDashBoardController.emailsInCurrentMailbox.clear();
|
||||
mailboxDashBoardController.listEmailSelected.clear();
|
||||
mailboxDashBoardController.currentSelectMode.value = SelectMode.INACTIVE;
|
||||
|
||||
@@ -413,9 +413,6 @@ class ThreadView extends GetWidget<ThreadController>
|
||||
pullDownToRefreshText: AppLocalizations.of(context).pullDownToRefresh,
|
||||
normalRefreshText: AppLocalizations.of(context).refresh,
|
||||
deepRefreshText: AppLocalizations.of(context).deepRefresh,
|
||||
refreshingText: AppLocalizations.of(context).refreshing,
|
||||
pullingText: AppLocalizations.of(context).pulling,
|
||||
pullFurtherForText: AppLocalizations.of(context).pullFurtherFor,
|
||||
pullHarderForText: AppLocalizations.of(context).pullHarderFor,
|
||||
child: listView,
|
||||
);
|
||||
@@ -699,9 +696,6 @@ class ThreadView extends GetWidget<ThreadController>
|
||||
pullDownToRefreshText: AppLocalizations.of(context).pullDownToRefresh,
|
||||
normalRefreshText: AppLocalizations.of(context).refresh,
|
||||
deepRefreshText: AppLocalizations.of(context).deepRefresh,
|
||||
refreshingText: AppLocalizations.of(context).refreshing,
|
||||
pullingText: AppLocalizations.of(context).pulling,
|
||||
pullFurtherForText: AppLocalizations.of(context).pullFurtherFor,
|
||||
pullHarderForText: AppLocalizations.of(context).pullHarderFor,
|
||||
child: EmptyEmailsWidget(
|
||||
key: const Key('empty_thread_view'),
|
||||
|
||||
Reference in New Issue
Block a user