TF-3507 Fix offline cache prevents updating email query view cache
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -968,6 +968,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.3"
|
||||
pull_to_refresh:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pull_to_refresh
|
||||
sha256: bbadd5a931837b57739cf08736bea63167e284e71fb23b218c8c9a6e042aad12
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
qr:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -97,6 +97,7 @@ export 'presentation/views/clipper/side_arrow_clipper.dart';
|
||||
export 'presentation/views/avatar/gradient_circle_avatar_icon.dart';
|
||||
export 'presentation/views/loading/cupertino_loading_widget.dart';
|
||||
export 'presentation/views/image/image_loader_mixin.dart';
|
||||
export 'presentation/views/pull_to_refresh/pull_to_refresh_widget.dart';
|
||||
|
||||
// Resources
|
||||
export 'presentation/resources/assets_paths.dart';
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/presentation/utils/theme_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
||||
|
||||
class PullToRefreshWidget extends StatefulWidget {
|
||||
final Widget child;
|
||||
final Future<void> Function() onNormalRefresh;
|
||||
final Future<void> Function() onDeepRefresh;
|
||||
final double deepRefreshThreshold;
|
||||
final String normalRefreshText;
|
||||
final String deepRefreshText;
|
||||
final String pullDownToRefreshText;
|
||||
final String refreshingText;
|
||||
final String pullingText;
|
||||
final String releaseToText;
|
||||
final String pullFurtherForText;
|
||||
final String pullHarderForText;
|
||||
final Icon? normalRefreshIcon;
|
||||
final Icon? deepRefreshIcon;
|
||||
|
||||
const PullToRefreshWidget({
|
||||
Key? key,
|
||||
required this.child,
|
||||
required this.onNormalRefresh,
|
||||
required this.onDeepRefresh,
|
||||
this.deepRefreshThreshold = 200.0,
|
||||
this.normalRefreshText = 'Refresh',
|
||||
this.deepRefreshText = 'Deep refresh',
|
||||
this.pullDownToRefreshText = 'Pull down to refresh',
|
||||
this.refreshingText = 'Refreshing',
|
||||
this.pullingText = 'Pulling',
|
||||
this.releaseToText = 'Release to',
|
||||
this.pullFurtherForText = 'Pull further for',
|
||||
this.pullHarderForText = 'Pull harder for',
|
||||
this.normalRefreshIcon = const Icon(Icons.refresh, size: 20),
|
||||
this.deepRefreshIcon = const Icon(Icons.autorenew, size: 20),
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<PullToRefreshWidget> createState() => _PullToRefreshWidgetState();
|
||||
}
|
||||
|
||||
class _PullToRefreshWidgetState extends State<PullToRefreshWidget> {
|
||||
final RefreshController _refreshController = RefreshController();
|
||||
double _scrollOffset = 0.0;
|
||||
String? _lastAction;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return NotificationListener<ScrollNotification>(
|
||||
onNotification: (notification) {
|
||||
if (notification is ScrollUpdateNotification) {
|
||||
setState(() {
|
||||
_scrollOffset = notification.metrics.pixels;
|
||||
});
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: SmartRefresher(
|
||||
controller: _refreshController,
|
||||
enablePullDown: true,
|
||||
enablePullUp: false,
|
||||
header: CustomHeader(
|
||||
builder: (context, mode) {
|
||||
String statusText;
|
||||
Icon? leadingIcon;
|
||||
|
||||
if (mode == RefreshStatus.idle) {
|
||||
statusText = widget.pullDownToRefreshText;
|
||||
leadingIcon = widget.normalRefreshIcon;
|
||||
} else if (mode == RefreshStatus.canRefresh) {
|
||||
if (_scrollOffset.abs() > widget.deepRefreshThreshold) {
|
||||
statusText = '${widget.releaseToText} ${widget.deepRefreshText}';
|
||||
leadingIcon = widget.deepRefreshIcon;
|
||||
} else {
|
||||
statusText = '${widget.releaseToText} ${widget.normalRefreshText}';
|
||||
leadingIcon = widget.normalRefreshIcon;
|
||||
}
|
||||
} else if (mode == RefreshStatus.refreshing || mode == RefreshStatus.completed) {
|
||||
statusText = '${widget.refreshingText}...';
|
||||
leadingIcon = _lastAction == widget.deepRefreshText
|
||||
? widget.deepRefreshIcon
|
||||
: widget.normalRefreshIcon;
|
||||
} else {
|
||||
statusText = '${widget.pullingText}...';
|
||||
leadingIcon = widget.normalRefreshIcon;
|
||||
}
|
||||
|
||||
return SizedBox(
|
||||
height: clampDouble(_scrollOffset.abs(), 60, widget.deepRefreshThreshold),
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
if (leadingIcon != null) leadingIcon,
|
||||
Flexible(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Text(
|
||||
statusText,
|
||||
style: ThemeUtils.textStyleBodyBody1(color: Colors.black),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (mode == RefreshStatus.canRefresh)
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.only(top: 4, start: 8, end: 8),
|
||||
child: Text(
|
||||
_scrollOffset.abs() > widget.deepRefreshThreshold
|
||||
? '${widget.pullFurtherForText} ${widget.deepRefreshText.toLowerCase()}'
|
||||
: '${widget.pullHarderForText} ${widget.deepRefreshText.toLowerCase()}',
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: AppColor.steelGray400,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
height: widget.deepRefreshThreshold,
|
||||
),
|
||||
onRefresh: () {
|
||||
if (_scrollOffset.abs() > widget.deepRefreshThreshold) {
|
||||
_lastAction = widget.deepRefreshText;
|
||||
widget.onDeepRefresh();
|
||||
} else {
|
||||
_lastAction = widget.normalRefreshText;
|
||||
widget.onNormalRefresh();
|
||||
}
|
||||
_refreshController.refreshCompleted();
|
||||
},
|
||||
child: widget.child,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_refreshController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
@@ -929,6 +929,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
pull_to_refresh:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: pull_to_refresh
|
||||
sha256: bbadd5a931837b57739cf08736bea63167e284e71fb23b218c8c9a6e042aad12
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
qr:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -102,6 +102,8 @@ dependencies:
|
||||
|
||||
win32: 5.5.1
|
||||
|
||||
pull_to_refresh: 2.0.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
@@ -25,5 +25,10 @@ class StateCacheManager {
|
||||
return await _stateCacheClient.insertItem(stateKey, stateCache);
|
||||
}
|
||||
|
||||
Future<void> deleteState(AccountId accountId, UserName userName, StateType stateType) async {
|
||||
final stateKey = TupleKey(stateType.name, accountId.asString, userName.value).encodeKey;
|
||||
return await _stateCacheClient.deleteItem(stateKey);
|
||||
}
|
||||
|
||||
Future<void> closeStateHiveCacheBox() => _stateCacheClient.closeBox();
|
||||
}
|
||||
+8
-1
@@ -103,6 +103,7 @@ import 'package:tmail_ui_user/features/offline_mode/manager/new_email_cache_work
|
||||
import 'package:tmail_ui_user/features/offline_mode/manager/opened_email_cache_manager.dart';
|
||||
import 'package:tmail_ui_user/features/offline_mode/manager/opened_email_cache_worker_queue.dart';
|
||||
import 'package:tmail_ui_user/features/offline_mode/manager/sending_email_cache_manager.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/data/local/fcm_cache_manager.dart';
|
||||
import 'package:tmail_ui_user/features/quotas/presentation/quotas_bindings.dart';
|
||||
import 'package:tmail_ui_user/features/search/email/domain/usecases/refresh_changes_search_email_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/search/email/presentation/search_email_bindings.dart';
|
||||
@@ -236,7 +237,13 @@ class MailboxDashBoardBindings extends BaseBindings {
|
||||
Get.find<ThreadAPI>(),
|
||||
Get.find<ThreadIsolateWorker>(),
|
||||
Get.find<RemoteExceptionThrower>()));
|
||||
Get.lazyPut(() => LocalThreadDataSourceImpl(Get.find<EmailCacheManager>(), Get.find<CacheExceptionThrower>()));
|
||||
Get.lazyPut(() => LocalThreadDataSourceImpl(
|
||||
Get.find<EmailCacheManager>(),
|
||||
Get.find<FCMCacheManager>(),
|
||||
Get.find<StateCacheManager>(),
|
||||
Get.find<FileUtils>(),
|
||||
Get.find<CacheExceptionThrower>(),
|
||||
));
|
||||
Get.lazyPut(() => StateDataSourceImpl(
|
||||
Get.find<StateCacheManager>(),
|
||||
Get.find<IOSSharingManager>(),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:fcm/model/type_name.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart' as jmap;
|
||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||
import 'package:model/extensions/account_id_extensions.dart';
|
||||
@@ -62,4 +63,20 @@ class FCMCacheManager {
|
||||
Future<void> deleteFirebaseRegistration() async {
|
||||
await _firebaseRegistrationCacheClient.deleteItem(FirebaseRegistrationCache.keyCacheValue);
|
||||
}
|
||||
|
||||
Future<void> clearAllEmailState(
|
||||
AccountId accountId,
|
||||
Session session,
|
||||
) async {
|
||||
await deleteStateToRefresh(
|
||||
accountId,
|
||||
session.username,
|
||||
TypeName.emailDelivery,
|
||||
);
|
||||
await deleteStateToRefresh(
|
||||
accountId,
|
||||
session.username,
|
||||
TypeName.emailType,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -76,4 +76,6 @@ abstract class ThreadDataSource {
|
||||
);
|
||||
|
||||
Future<PresentationEmail> getEmailById(Session session, AccountId accountId, EmailId emailId, {Properties? properties});
|
||||
|
||||
Future<void> clearEmailCacheAndStateCache(AccountId accountId, Session session);
|
||||
}
|
||||
@@ -2,6 +2,8 @@ import 'dart:async';
|
||||
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:core/utils/file_utils.dart';
|
||||
import 'package:core/utils/platform_info.dart';
|
||||
import 'package:dartz/dartz.dart' as dartz;
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/filter/filter.dart';
|
||||
@@ -14,6 +16,10 @@ import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:model/email/presentation_email.dart';
|
||||
import 'package:tmail_ui_user/features/caching/utils/caching_constants.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/local/state_cache_manager.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/model/state_type.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/local/email_cache_manager.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/model/email_change_response.dart';
|
||||
@@ -25,9 +31,18 @@ import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
|
||||
class LocalThreadDataSourceImpl extends ThreadDataSource {
|
||||
|
||||
final EmailCacheManager _emailCacheManager;
|
||||
final FCMCacheManager _fcmCacheManager;
|
||||
final StateCacheManager _stateCacheManager;
|
||||
final FileUtils _fileUtils;
|
||||
final ExceptionThrower _exceptionThrower;
|
||||
|
||||
LocalThreadDataSourceImpl(this._emailCacheManager, this._exceptionThrower);
|
||||
LocalThreadDataSourceImpl(
|
||||
this._emailCacheManager,
|
||||
this._fcmCacheManager,
|
||||
this._stateCacheManager,
|
||||
this._fileUtils,
|
||||
this._exceptionThrower,
|
||||
);
|
||||
|
||||
@override
|
||||
Future<EmailsResponse> getAllEmail(
|
||||
@@ -125,4 +140,20 @@ class LocalThreadDataSourceImpl extends ThreadDataSource {
|
||||
Future<PresentationEmail> getEmailById(Session session, AccountId accountId, EmailId emailId, {Properties? properties}) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> clearEmailCacheAndStateCache(AccountId accountId, Session session) {
|
||||
return Future.sync(() async {
|
||||
return await Future.wait([
|
||||
_stateCacheManager.deleteState(accountId, session.username, StateType.email),
|
||||
_emailCacheManager.clearAll(),
|
||||
if (PlatformInfo.isMobile)
|
||||
...[
|
||||
_fileUtils.removeFolder(CachingConstants.newEmailsContentFolderName),
|
||||
_fileUtils.removeFolder(CachingConstants.openedEmailContentFolderName),
|
||||
_fcmCacheManager.clearAllEmailState(accountId, session),
|
||||
],
|
||||
]);
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
}
|
||||
@@ -140,4 +140,9 @@ class ThreadDataSourceImpl extends ThreadDataSource {
|
||||
return email.toPresentationEmail();
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> clearEmailCacheAndStateCache(AccountId accountId, Session session) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
@@ -90,6 +90,10 @@ class EmailCacheManager {
|
||||
await _emailCacheClient.deleteMultipleItem(listEmailIdCacheExpire);
|
||||
}
|
||||
|
||||
Future<void> clearAll() async {
|
||||
return await _emailCacheClient.clearAllData();
|
||||
}
|
||||
|
||||
Future<void> storeEmail(AccountId accountId, UserName userName, EmailCache emailCache) {
|
||||
final keyCache = TupleKey(emailCache.id, accountId.asString, userName.value).encodeKey;
|
||||
return _emailCacheClient.insertItem(keyCache, emailCache);
|
||||
|
||||
@@ -432,4 +432,13 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
||||
|
||||
return listEmailIdDeleted;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> clearEmailCacheAndStateCache(
|
||||
AccountId accountId,
|
||||
Session session,
|
||||
) => mapDataSource[DataSourceType.local]!.clearEmailCacheAndStateCache(
|
||||
accountId,
|
||||
session,
|
||||
);
|
||||
}
|
||||
@@ -80,4 +80,6 @@ abstract class ThreadRepository {
|
||||
int totalEmails,
|
||||
StreamController<dartz.Either<Failure, Success>> onProgressController
|
||||
);
|
||||
|
||||
Future<void> clearEmailCacheAndStateCache(AccountId accountId, Session session);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
|
||||
class CleanAndGetAllEmailLoading extends LoadingState {}
|
||||
|
||||
class CleanAndGetAllEmailFailure extends FeatureFailure {
|
||||
|
||||
CleanAndGetAllEmailFailure(dynamic exception) : super(exception: exception);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/properties/properties.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/sort/comparator.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/unsigned_int.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/email_filter.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/repository/thread_repository.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/usecases/get_emails_in_mailbox_interactor.dart';
|
||||
|
||||
class CleanAndGetEmailsInMailboxInteractor {
|
||||
final GetEmailsInMailboxInteractor _getEmailsInMailboxInteractor;
|
||||
final ThreadRepository _threadRepository;
|
||||
|
||||
const CleanAndGetEmailsInMailboxInteractor(
|
||||
this._threadRepository,
|
||||
this._getEmailsInMailboxInteractor,
|
||||
);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
{
|
||||
UnsignedInt? limit,
|
||||
Set<Comparator>? sort,
|
||||
EmailFilter? emailFilter,
|
||||
Properties? propertiesCreated,
|
||||
Properties? propertiesUpdated,
|
||||
bool getLatestChanges = true,
|
||||
}
|
||||
) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(CleanAndGetAllEmailLoading());
|
||||
|
||||
await _threadRepository.clearEmailCacheAndStateCache(accountId, session);
|
||||
|
||||
yield* _getEmailsInMailboxInteractor.execute(
|
||||
session,
|
||||
accountId,
|
||||
limit: limit,
|
||||
sort: sort,
|
||||
emailFilter: emailFilter,
|
||||
propertiesCreated: propertiesCreated,
|
||||
propertiesUpdated: propertiesUpdated,
|
||||
getLatestChanges: getLatestChanges,
|
||||
);
|
||||
} catch (e) {
|
||||
yield Left(CleanAndGetAllEmailFailure(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
|
||||
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/presentation/model/loading_more_status.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/thread_controller.dart';
|
||||
|
||||
extension HandlePullToRefreshListEmailExtension on ThreadController {
|
||||
|
||||
Future<void> onRefresh() async {
|
||||
log('HandlePullToRefreshListEmailExtension::onRefresh:Started');
|
||||
canLoadMore = false;
|
||||
loadingMoreStatus.value == LoadingMoreStatus.idle;
|
||||
getAllEmailAction();
|
||||
}
|
||||
|
||||
Future<void> onCleanAndRefresh() async {
|
||||
log('HandlePullToRefreshListEmailExtension::onCleanAndRefresh:Started');
|
||||
canLoadMore = false;
|
||||
loadingMoreStatus.value == LoadingMoreStatus.idle;
|
||||
cleanAndGetAllEmailAction();
|
||||
}
|
||||
|
||||
Future<void> cleanAndGetAllEmailAction() async {
|
||||
final accountId = mailboxDashBoardController.accountId.value;
|
||||
final session = mailboxDashBoardController.sessionCurrent;
|
||||
|
||||
if (accountId == null || session == null) {
|
||||
consumeState(Stream.value(Left(CleanAndGetAllEmailFailure(NotFoundSessionException()))));
|
||||
return;
|
||||
}
|
||||
|
||||
consumeState(cleanAndGetEmailsInMailboxInteractor.execute(
|
||||
session,
|
||||
accountId,
|
||||
limit: ThreadConstants.defaultLimit,
|
||||
sort: EmailSortOrderType.mostRecent.getSortOrder().toNullable(),
|
||||
emailFilter: EmailFilter(
|
||||
filter: getFilterCondition(mailboxIdSelected: selectedMailboxId),
|
||||
filterOption: mailboxDashBoardController.filterMessageOption.value,
|
||||
mailboxId: selectedMailboxId,
|
||||
),
|
||||
propertiesCreated: EmailUtils.getPropertiesForEmailGetMethod(session, accountId),
|
||||
propertiesUpdated: ThreadConstants.propertiesUpdatedDefault,
|
||||
getLatestChanges: true,
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
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/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';
|
||||
@@ -13,6 +15,7 @@ import 'package:tmail_ui_user/features/thread/data/network/thread_api.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/network/thread_isolate_worker.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/repository/thread_repository_impl.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/repository/thread_repository.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/clean_and_get_emails_in_mailbox_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/get_email_by_id_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/get_emails_in_mailbox_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/load_more_emails_in_mailbox_interactor.dart';
|
||||
@@ -35,6 +38,7 @@ class ThreadBindings extends BaseBindings {
|
||||
Get.find<SearchEmailInteractor>(),
|
||||
Get.find<SearchMoreEmailInteractor>(),
|
||||
Get.find<GetEmailByIdInteractor>(),
|
||||
Get.find<CleanAndGetEmailsInMailboxInteractor>(),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -50,7 +54,13 @@ class ThreadBindings extends BaseBindings {
|
||||
Get.find<ThreadAPI>(),
|
||||
Get.find<ThreadIsolateWorker>(),
|
||||
Get.find<RemoteExceptionThrower>()));
|
||||
Get.lazyPut(() => LocalThreadDataSourceImpl(Get.find<EmailCacheManager>(), Get.find<CacheExceptionThrower>()));
|
||||
Get.lazyPut(() => LocalThreadDataSourceImpl(
|
||||
Get.find<EmailCacheManager>(),
|
||||
Get.find<FCMCacheManager>(),
|
||||
Get.find<StateCacheManager>(),
|
||||
Get.find<FileUtils>(),
|
||||
Get.find<CacheExceptionThrower>(),
|
||||
));
|
||||
Get.lazyPut(() => StateDataSourceImpl(
|
||||
Get.find<StateCacheManager>(),
|
||||
Get.find<IOSSharingManager>(),
|
||||
@@ -66,6 +76,10 @@ class ThreadBindings extends BaseBindings {
|
||||
Get.lazyPut(() => SearchEmailInteractor(Get.find<ThreadRepository>()));
|
||||
Get.lazyPut(() => SearchMoreEmailInteractor(Get.find<ThreadRepository>()));
|
||||
Get.lazyPut(() => GetEmailByIdInteractor(Get.find<ThreadRepository>(), Get.find<EmailRepository>()));
|
||||
Get.lazyPut(() => CleanAndGetEmailsInMailboxInteractor(
|
||||
Get.find<ThreadRepository>(),
|
||||
Get.find<GetEmailsInMailboxInteractor>(),
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -48,6 +48,7 @@ import 'package:tmail_ui_user/features/thread/domain/model/email_filter.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/filter_message_option.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/get_email_request.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/search_query.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/domain/state/get_email_by_id_state.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/state/load_more_emails_state.dart';
|
||||
@@ -56,6 +57,7 @@ import 'package:tmail_ui_user/features/thread/domain/state/refresh_all_email_sta
|
||||
import 'package:tmail_ui_user/features/thread/domain/state/refresh_changes_all_email_state.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/state/search_email_state.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/state/search_more_email_state.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/clean_and_get_emails_in_mailbox_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/get_email_by_id_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/get_emails_in_mailbox_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/load_more_emails_in_mailbox_interactor.dart';
|
||||
@@ -89,6 +91,7 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
final SearchEmailInteractor _searchEmailInteractor;
|
||||
final SearchMoreEmailInteractor _searchMoreEmailInteractor;
|
||||
final GetEmailByIdInteractor _getEmailByIdInteractor;
|
||||
final CleanAndGetEmailsInMailboxInteractor cleanAndGetEmailsInMailboxInteractor;
|
||||
|
||||
CreateNewEmailRuleFilterInteractor? _createNewEmailRuleFilterInteractor;
|
||||
|
||||
@@ -101,11 +104,11 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
bool canSearchMore = false;
|
||||
MailboxId? _currentMemoryMailboxId;
|
||||
final ScrollController listEmailController = ScrollController();
|
||||
final FocusNode focusNodeKeyBoard = FocusNode();
|
||||
final latestEmailSelectedOrUnselected = Rxn<PresentationEmail>();
|
||||
@visibleForTesting
|
||||
bool isListEmailScrollViewJumping = false;
|
||||
WebSocketQueueHandler? _webSocketQueueHandler;
|
||||
FocusNode? focusNodeKeyBoard;
|
||||
|
||||
StreamSubscription<html.Event>? _resizeBrowserStreamSubscription;
|
||||
|
||||
@@ -130,12 +133,14 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
this._searchEmailInteractor,
|
||||
this._searchMoreEmailInteractor,
|
||||
this._getEmailByIdInteractor,
|
||||
this.cleanAndGetEmailsInMailboxInteractor,
|
||||
);
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
_registerObxStreamListener();
|
||||
if (PlatformInfo.isWeb) {
|
||||
focusNodeKeyBoard = FocusNode();
|
||||
_registerBrowserResizeListener();
|
||||
}
|
||||
_initWebSocketQueueHandler();
|
||||
@@ -152,7 +157,8 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
void onClose() {
|
||||
_currentMemoryMailboxId = null;
|
||||
listEmailController.dispose();
|
||||
focusNodeKeyBoard.dispose();
|
||||
focusNodeKeyBoard?.dispose();
|
||||
focusNodeKeyBoard = null;
|
||||
if (PlatformInfo.isWeb) {
|
||||
_resizeBrowserStreamSubscription?.cancel();
|
||||
}
|
||||
@@ -211,7 +217,7 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
} else if (failure is GetEmailByIdFailure) {
|
||||
openingEmail.value = false;
|
||||
popAndPush(AppRoutes.unknownRoutePage);
|
||||
} else if (failure is GetAllEmailFailure) {
|
||||
} else if (failure is GetAllEmailFailure || failure is CleanAndGetAllEmailFailure) {
|
||||
mailboxDashBoardController.updateRefreshAllEmailState(Left(RefreshAllEmailFailure()));
|
||||
canLoadMore = true;
|
||||
}
|
||||
@@ -262,7 +268,7 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
_currentMemoryMailboxId = mailbox.id;
|
||||
consumeState(Stream.value(Right(GetAllEmailLoading())));
|
||||
_resetToOriginalValue();
|
||||
_getAllEmailAction(
|
||||
getAllEmailAction(
|
||||
getLatestChanges: mailboxDashBoardController.isFirstSessionLoad,
|
||||
);
|
||||
mailboxDashBoardController.setIsFirstSessionLoad(false);
|
||||
@@ -542,7 +548,7 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
}
|
||||
}
|
||||
|
||||
void _getAllEmailAction({
|
||||
void getAllEmailAction({
|
||||
bool getLatestChanges = true,
|
||||
}) {
|
||||
log('ThreadController::_getAllEmailAction:getLatestChanges = $getLatestChanges');
|
||||
@@ -553,7 +559,7 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
limit: ThreadConstants.defaultLimit,
|
||||
sort: EmailSortOrderType.mostRecent.getSortOrder().toNullable(),
|
||||
emailFilter: EmailFilter(
|
||||
filter: _getFilterCondition(mailboxIdSelected: selectedMailboxId),
|
||||
filter: getFilterCondition(mailboxIdSelected: selectedMailboxId),
|
||||
filterOption: mailboxDashBoardController.filterMessageOption.value,
|
||||
mailboxId: selectedMailboxId
|
||||
),
|
||||
@@ -566,16 +572,7 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
}
|
||||
}
|
||||
|
||||
@visibleForTesting
|
||||
EmailFilterCondition getFilterCondition({
|
||||
PresentationEmail? oldestEmail,
|
||||
MailboxId? mailboxIdSelected,
|
||||
}) => _getFilterCondition(
|
||||
oldestEmail: oldestEmail,
|
||||
mailboxIdSelected: mailboxIdSelected,
|
||||
);
|
||||
|
||||
EmailFilterCondition _getFilterCondition({PresentationEmail? oldestEmail, MailboxId? mailboxIdSelected}) {
|
||||
EmailFilterCondition getFilterCondition({PresentationEmail? oldestEmail, MailboxId? mailboxIdSelected}) {
|
||||
switch(mailboxDashBoardController.filterMessageOption.value) {
|
||||
case FilterMessageOption.all:
|
||||
return EmailFilterCondition(
|
||||
@@ -617,7 +614,7 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
if (searchController.isSearchEmailRunning) {
|
||||
_searchEmail(limit: limitEmailFetched);
|
||||
} else {
|
||||
_getAllEmailAction();
|
||||
getAllEmailAction();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -689,7 +686,7 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
position: _searchEmailFilter.position,
|
||||
sort: _searchEmailFilter.sortOrderType.getSortOrder().toNullable(),
|
||||
filter: _searchEmailFilter.mappingToEmailFilterCondition(
|
||||
moreFilterCondition: _getFilterCondition(),
|
||||
moreFilterCondition: getFilterCondition(),
|
||||
),
|
||||
properties: EmailUtils.getPropertiesForEmailGetMethod(
|
||||
_session!,
|
||||
@@ -724,7 +721,7 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
),
|
||||
propertiesUpdated: ThreadConstants.propertiesUpdatedDefault,
|
||||
emailFilter: EmailFilter(
|
||||
filter: _getFilterCondition(mailboxIdSelected: selectedMailboxId),
|
||||
filter: getFilterCondition(mailboxIdSelected: selectedMailboxId),
|
||||
filterOption: mailboxDashBoardController.filterMessageOption.value,
|
||||
mailboxId: selectedMailboxId,
|
||||
),
|
||||
@@ -759,7 +756,7 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
limit: ThreadConstants.defaultLimit,
|
||||
sort: EmailSortOrderType.mostRecent.getSortOrder().toNullable(),
|
||||
filterOption: mailboxDashBoardController.filterMessageOption.value,
|
||||
filter: _getFilterCondition(oldestEmail: oldestEmail, mailboxIdSelected: selectedMailboxId),
|
||||
filter: getFilterCondition(oldestEmail: oldestEmail, mailboxIdSelected: selectedMailboxId),
|
||||
properties: EmailUtils.getPropertiesForEmailGetMethod(_session!, _accountId!),
|
||||
lastEmailId: oldestEmail?.id
|
||||
)
|
||||
@@ -873,8 +870,8 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
latestEmailSelectedOrUnselected.value = emailsInCurrentMailbox
|
||||
.firstWhereOrNull((e) => e.id == presentationEmailSelected.id);
|
||||
|
||||
if (!PlatformInfo.isMobile) {
|
||||
focusNodeKeyBoard.requestFocus();
|
||||
if (PlatformInfo.isWeb) {
|
||||
focusNodeKeyBoard?.requestFocus();
|
||||
}
|
||||
|
||||
if (_isUnSelectedAll()) {
|
||||
@@ -986,7 +983,7 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
position: _searchEmailFilter.position,
|
||||
sort: _searchEmailFilter.sortOrderType.getSortOrder().toNullable(),
|
||||
filter: _searchEmailFilter.mappingToEmailFilterCondition(
|
||||
moreFilterCondition: _getFilterCondition()
|
||||
moreFilterCondition: getFilterCondition()
|
||||
),
|
||||
properties: EmailUtils.getPropertiesForEmailGetMethod(_session!, _accountId!),
|
||||
needRefreshSearchState: needRefreshSearchState
|
||||
@@ -1066,7 +1063,7 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
sort: _searchEmailFilter.sortOrderType.getSortOrder().toNullable(),
|
||||
position: _searchEmailFilter.position,
|
||||
filter: _searchEmailFilter.mappingToEmailFilterCondition(
|
||||
moreFilterCondition: _getFilterCondition()
|
||||
moreFilterCondition: getFilterCondition()
|
||||
),
|
||||
properties: EmailUtils.getPropertiesForEmailGetMethod(_session!, _accountId!),
|
||||
lastEmailId: lastEmail?.id
|
||||
|
||||
@@ -20,10 +20,12 @@ import 'package:tmail_ui_user/features/manage_account/presentation/vacation/widg
|
||||
import 'package:tmail_ui_user/features/network_connection/presentation/network_connection_banner_widget.dart';
|
||||
import 'package:tmail_ui_user/features/quotas/presentation/widget/quotas_banner_widget.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/filter_message_option.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/empty_spam_folder_state.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/state/empty_trash_folder_state.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/state/get_all_email_state.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/state/search_email_state.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/extensions/handle_pull_to_refresh_list_email_extension.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/model/delete_action_type.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/model/loading_more_status.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/styles/item_email_tile_styles.dart';
|
||||
@@ -341,90 +343,94 @@ class ThreadView extends GetWidget<ThreadController>
|
||||
}
|
||||
|
||||
Widget _buildResultListEmail(BuildContext context, List<PresentationEmail> listPresentationEmail) {
|
||||
if (controller.mailboxDashBoardController.currentSelectMode.value == SelectMode.INACTIVE) {
|
||||
return listPresentationEmail.isNotEmpty
|
||||
? RefreshIndicator(
|
||||
color: AppColor.colorTextButton,
|
||||
onRefresh: () async => controller.refreshAllEmail(),
|
||||
child: _buildListEmailBody(context, listPresentationEmail))
|
||||
: RefreshIndicator(
|
||||
color: AppColor.colorTextButton,
|
||||
onRefresh: () async => controller.refreshAllEmail(),
|
||||
child: _buildEmptyEmail(context));
|
||||
} else {
|
||||
return listPresentationEmail.isNotEmpty
|
||||
return listPresentationEmail.isNotEmpty
|
||||
? _buildListEmailBody(context, listPresentationEmail)
|
||||
: _buildEmptyEmail(context);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildListEmailBody(BuildContext context, List<PresentationEmail> listPresentationEmail) {
|
||||
Widget listView = ListView.separated(
|
||||
key: const PageStorageKey('list_presentation_email_in_threads'),
|
||||
controller: controller.listEmailController,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
itemCount: listPresentationEmail.length + 2,
|
||||
itemBuilder: (context, index) => Obx(() {
|
||||
if (index == listPresentationEmail.length) {
|
||||
return _buildLoadMoreButton(
|
||||
context,
|
||||
controller.loadingMoreStatus.value,
|
||||
);
|
||||
}
|
||||
if (index == listPresentationEmail.length + 1) {
|
||||
return _buildLoadMoreProgressBar(controller.loadingMoreStatus.value);
|
||||
}
|
||||
|
||||
if (PlatformInfo.isMobile) {
|
||||
return _buildEmailItemNotDraggable(
|
||||
context,
|
||||
listPresentationEmail[index],
|
||||
);
|
||||
} else {
|
||||
return _buildEmailItem(
|
||||
context,
|
||||
listPresentationEmail[index],
|
||||
);
|
||||
}
|
||||
}),
|
||||
separatorBuilder: (context, index) {
|
||||
if (PlatformInfo.isMobile) {
|
||||
if (index < listPresentationEmail.length - 1) {
|
||||
return Padding(
|
||||
padding: ItemEmailTileStyles.getMobilePaddingItemList(
|
||||
context,
|
||||
controller.responsiveUtils,
|
||||
),
|
||||
child: const Divider(),
|
||||
);
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
} else {
|
||||
return Padding(
|
||||
padding: ItemEmailTileStyles.getPaddingDividerWeb(
|
||||
context,
|
||||
controller.responsiveUtils,
|
||||
),
|
||||
child: Divider(
|
||||
color: index < listPresentationEmail.length - 1 && controller.mailboxDashBoardController.currentSelectMode.value == SelectMode.INACTIVE
|
||||
? null
|
||||
: Colors.white,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
if (!controller.mailboxDashBoardController.isSelectionEnabled()) {
|
||||
listView = PullToRefreshWidget(
|
||||
onNormalRefresh: controller.onRefresh,
|
||||
onDeepRefresh: controller.onCleanAndRefresh,
|
||||
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,
|
||||
);
|
||||
}
|
||||
|
||||
return NotificationListener<ScrollNotification>(
|
||||
onNotification: _handleScrollNotificationListener,
|
||||
child: PlatformInfo.isMobile
|
||||
? ListView.separated(
|
||||
key: const PageStorageKey('list_presentation_email_in_threads'),
|
||||
controller: controller.listEmailController,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
itemCount: listPresentationEmail.length + 2,
|
||||
itemBuilder: (context, index) => Obx(() {
|
||||
if (index == listPresentationEmail.length) {
|
||||
return _buildLoadMoreButton(
|
||||
context,
|
||||
controller.loadingMoreStatus.value);
|
||||
}
|
||||
if (index == listPresentationEmail.length + 1) {
|
||||
return _buildLoadMoreProgressBar(controller.loadingMoreStatus.value);
|
||||
}
|
||||
return _buildEmailItemNotDraggable(
|
||||
context,
|
||||
listPresentationEmail[index]);
|
||||
}),
|
||||
separatorBuilder: (context, index) {
|
||||
if (index < listPresentationEmail.length - 1) {
|
||||
return Padding(
|
||||
padding: ItemEmailTileStyles.getMobilePaddingItemList(context, controller.responsiveUtils),
|
||||
child: const Divider());
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
},
|
||||
)
|
||||
? listView
|
||||
: Focus(
|
||||
focusNode: controller.focusNodeKeyBoard,
|
||||
autofocus: true,
|
||||
onKeyEvent: controller.handleKeyEvent,
|
||||
child: ListView.separated(
|
||||
key: const PageStorageKey('list_presentation_email_in_threads'),
|
||||
controller: controller.listEmailController,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
itemCount: listPresentationEmail.length + 2,
|
||||
itemBuilder: (context, index) => Obx(() {
|
||||
if (index == listPresentationEmail.length) {
|
||||
return _buildLoadMoreButton(
|
||||
context,
|
||||
controller.loadingMoreStatus.value);
|
||||
}
|
||||
if (index == listPresentationEmail.length + 1) {
|
||||
return _buildLoadMoreProgressBar(controller.loadingMoreStatus.value);
|
||||
}
|
||||
return _buildEmailItem(
|
||||
context,
|
||||
listPresentationEmail[index]);
|
||||
}),
|
||||
separatorBuilder: (context, index) {
|
||||
return Padding(
|
||||
padding: ItemEmailTileStyles.getPaddingDividerWeb(context, controller.responsiveUtils),
|
||||
child: Divider(
|
||||
color: index < listPresentationEmail.length - 1 &&
|
||||
controller.mailboxDashBoardController.currentSelectMode.value == SelectMode.INACTIVE
|
||||
? null
|
||||
: Colors.white,
|
||||
)
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
child: listView,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -677,7 +683,9 @@ class ThreadView extends GetWidget<ThreadController>
|
||||
return Obx(() => controller.viewState.value.fold(
|
||||
(failure) => const SizedBox.shrink(),
|
||||
(success) {
|
||||
if (success is GetAllEmailLoading || success is SearchingState) {
|
||||
if (success is GetAllEmailLoading ||
|
||||
success is SearchingState ||
|
||||
success is CleanAndGetAllEmailLoading) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
@@ -685,12 +693,23 @@ class ThreadView extends GetWidget<ThreadController>
|
||||
&& success.currentMailboxId != controller.selectedMailboxId) {
|
||||
return const SizedBox.shrink();
|
||||
} else {
|
||||
return EmptyEmailsWidget(
|
||||
key: const Key('empty_thread_view'),
|
||||
isNetworkConnectionAvailable: controller.networkConnectionController.isNetworkConnectionAvailable(),
|
||||
isSearchActive: controller.isSearchActive,
|
||||
isFilterMessageActive: controller.mailboxDashBoardController.filterMessageOption.value != FilterMessageOption.all,
|
||||
onCreateFiltersActionCallback: controller.goToCreateEmailRuleView
|
||||
return PullToRefreshWidget(
|
||||
onNormalRefresh: controller.onRefresh,
|
||||
onDeepRefresh: controller.onCleanAndRefresh,
|
||||
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'),
|
||||
isNetworkConnectionAvailable: controller.networkConnectionController.isNetworkConnectionAvailable(),
|
||||
isSearchActive: controller.isSearchActive,
|
||||
isFilterMessageActive: controller.mailboxDashBoardController.filterMessageOption.value != FilterMessageOption.all,
|
||||
onCreateFiltersActionCallback: controller.goToCreateEmailRuleView
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:core/presentation/state/success.dart';
|
||||
import 'package:core/presentation/views/loading/cupertino_loading_widget.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flutter/material.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/domain/state/search_email_state.dart';
|
||||
|
||||
@@ -20,7 +21,9 @@ class ThreadViewLoadingBarWidget extends StatelessWidget {
|
||||
return viewState.fold(
|
||||
(failure) => const SizedBox.shrink(),
|
||||
(success) {
|
||||
if (success is SearchingState || success is GetAllEmailLoading) {
|
||||
if (success is SearchingState ||
|
||||
success is GetAllEmailLoading ||
|
||||
success is CleanAndGetAllEmailLoading) {
|
||||
return const Padding(
|
||||
padding: EdgeInsetsDirectional.only(top: 16),
|
||||
child: CupertinoLoadingWidget());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"@@last_modified": "2025-03-31T03:40:41.454034",
|
||||
"@@last_modified": "2025-04-03T14:19:11.171517",
|
||||
"initializing_data": "Initializing data...",
|
||||
"@initializing_data": {
|
||||
"type": "text",
|
||||
@@ -2968,6 +2968,12 @@
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"errorWhileFetchingSubaddress": "Error while fetching the subaddress",
|
||||
"@errorWhileFetchingSubaddress": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"connectedToTheInternet": "Connected to the internet",
|
||||
"@connectedToTheInternet": {
|
||||
"type": "text",
|
||||
@@ -4399,5 +4405,53 @@
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"refresh": "Refresh",
|
||||
"@refresh": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"deepRefresh": "Deep refresh",
|
||||
"@deepRefresh": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"pullDownToRefresh": "Pull down to refresh",
|
||||
"@pullDownToRefresh": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"refreshing": "Refreshing",
|
||||
"@refreshing": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"pulling": "Pulling",
|
||||
"@pulling": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"releaseTo": "Release to",
|
||||
"@releaseTo": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"pullFurtherFor": "Pull further for",
|
||||
"@pullFurtherFor": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"pullHarderFor": "Pull harder for",
|
||||
"@pullHarderFor": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
}
|
||||
}
|
||||
@@ -4625,4 +4625,60 @@ class AppLocalizations {
|
||||
name: 'retry',
|
||||
);
|
||||
}
|
||||
|
||||
String get refresh {
|
||||
return Intl.message(
|
||||
'Refresh',
|
||||
name: 'refresh',
|
||||
);
|
||||
}
|
||||
|
||||
String get deepRefresh {
|
||||
return Intl.message(
|
||||
'Deep refresh',
|
||||
name: 'deepRefresh',
|
||||
);
|
||||
}
|
||||
|
||||
String get pullDownToRefresh {
|
||||
return Intl.message(
|
||||
'Pull down to refresh',
|
||||
name: 'pullDownToRefresh',
|
||||
);
|
||||
}
|
||||
|
||||
String get refreshing {
|
||||
return Intl.message(
|
||||
'Refreshing',
|
||||
name: 'refreshing',
|
||||
);
|
||||
}
|
||||
|
||||
String get pulling {
|
||||
return Intl.message(
|
||||
'Pulling',
|
||||
name: 'pulling',
|
||||
);
|
||||
}
|
||||
|
||||
String get releaseTo {
|
||||
return Intl.message(
|
||||
'Release to',
|
||||
name: 'releaseTo',
|
||||
);
|
||||
}
|
||||
|
||||
String get pullFurtherFor {
|
||||
return Intl.message(
|
||||
'Pull further for',
|
||||
name: 'pullFurtherFor',
|
||||
);
|
||||
}
|
||||
|
||||
String get pullHarderFor {
|
||||
return Intl.message(
|
||||
'Pull harder for',
|
||||
name: 'pullHarderFor',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -945,6 +945,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.3"
|
||||
pull_to_refresh:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pull_to_refresh
|
||||
sha256: bbadd5a931837b57739cf08736bea63167e284e71fb23b218c8c9a6e042aad12
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
qr:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -1793,6 +1793,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.3"
|
||||
pull_to_refresh:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pull_to_refresh
|
||||
sha256: bbadd5a931837b57739cf08736bea63167e284e71fb23b218c8c9a6e042aad12
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
qr:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
+8
-2
@@ -81,6 +81,7 @@ import 'package:tmail_ui_user/features/thread/domain/constants/thread_constants.
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/email_filter.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/filter_message_option.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/search_query.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/clean_and_get_emails_in_mailbox_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/empty_spam_folder_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/empty_trash_folder_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/get_email_by_id_interactor.dart';
|
||||
@@ -182,6 +183,7 @@ const fallbackGenerators = {
|
||||
MockSpec<GetAllIdentitiesInteractor>(),
|
||||
MockSpec<GetIdentityCacheOnWebInteractor>(),
|
||||
MockSpec<ComposerManager>(fallbackGenerators: fallbackGenerators),
|
||||
MockSpec<CleanAndGetEmailsInMailboxInteractor>(),
|
||||
])
|
||||
void main() {
|
||||
// mock mailbox dashboard controller direct dependencies
|
||||
@@ -203,6 +205,7 @@ void main() {
|
||||
final deleteMultipleEmailsPermanentlyInteractor =
|
||||
MockDeleteMultipleEmailsPermanentlyInteractor();
|
||||
final getEmailByIdInteractor = MockGetEmailByIdInteractor();
|
||||
final cleanAndGetEmailsInMailboxInteractor = MockCleanAndGetEmailsInMailboxInteractor();
|
||||
final sendEmailInteractor = MockSendEmailInteractor();
|
||||
final storeSendingEmailInteractor = MockStoreSendingEmailInteractor();
|
||||
final updateSendingEmailInteractor = MockUpdateSendingEmailInteractor();
|
||||
@@ -391,7 +394,8 @@ void main() {
|
||||
loadMoreEmailsInMailboxInteractor,
|
||||
searchEmailInteractor,
|
||||
searchMoreEmailInteractor,
|
||||
getEmailByIdInteractor);
|
||||
getEmailByIdInteractor,
|
||||
cleanAndGetEmailsInMailboxInteractor);
|
||||
Get.put(threadController);
|
||||
|
||||
advancedFilterController = AdvancedFilterController();
|
||||
@@ -622,7 +626,9 @@ void main() {
|
||||
loadMoreEmailsInMailboxInteractor,
|
||||
searchEmailInteractor,
|
||||
searchMoreEmailInteractor,
|
||||
getEmailByIdInteractor);
|
||||
getEmailByIdInteractor,
|
||||
cleanAndGetEmailsInMailboxInteractor,
|
||||
);
|
||||
Get.put(threadController);
|
||||
|
||||
advancedFilterController = AdvancedFilterController();
|
||||
|
||||
+5
-20
@@ -79,6 +79,7 @@ import 'package:tmail_ui_user/features/sending_queue/domain/usecases/update_send
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/filter_message_option.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/state/get_all_email_state.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/state/load_more_emails_state.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/clean_and_get_emails_in_mailbox_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/empty_spam_folder_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/empty_trash_folder_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/get_email_by_id_interactor.dart';
|
||||
@@ -184,6 +185,7 @@ const fallbackGenerators = {
|
||||
MockSpec<TwakeAppManager>(),
|
||||
MockSpec<GetIdentityCacheOnWebInteractor>(),
|
||||
MockSpec<ComposerManager>(fallbackGenerators: fallbackGenerators),
|
||||
MockSpec<CleanAndGetEmailsInMailboxInteractor>(),
|
||||
])
|
||||
void main() {
|
||||
final moveToMailboxInteractor = MockMoveToMailboxInteractor();
|
||||
@@ -199,6 +201,7 @@ void main() {
|
||||
final emptyTrashFolderInteractor = MockEmptyTrashFolderInteractor();
|
||||
final deleteMultipleEmailsPermanentlyInteractor = MockDeleteMultipleEmailsPermanentlyInteractor();
|
||||
final getEmailByIdInteractor = MockGetEmailByIdInteractor();
|
||||
final cleanAndGetEmailsInMailboxInteractor = MockCleanAndGetEmailsInMailboxInteractor();
|
||||
final sendEmailInteractor = MockSendEmailInteractor();
|
||||
final storeSendingEmailInteractor = MockStoreSendingEmailInteractor();
|
||||
final updateSendingEmailInteractor = MockUpdateSendingEmailInteractor();
|
||||
@@ -383,7 +386,8 @@ void main() {
|
||||
loadMoreEmailsInMailboxInteractor,
|
||||
searchEmailInteractor,
|
||||
searchMoreEmailInteractor,
|
||||
getEmailByIdInteractor
|
||||
getEmailByIdInteractor,
|
||||
cleanAndGetEmailsInMailboxInteractor,
|
||||
);
|
||||
Get.put(threadController);
|
||||
|
||||
@@ -433,9 +437,6 @@ void main() {
|
||||
final listViewEmailWidgetFinder = find.byKey(const PageStorageKey('list_presentation_email_in_threads'));
|
||||
expect(listViewEmailWidgetFinder, findsOneWidget);
|
||||
|
||||
final listViewEmailWidget = tester.widget<ListView>(listViewEmailWidgetFinder);
|
||||
expect(listViewEmailWidget.semanticChildCount, equals(listEmailsOfInbox.length + 2));
|
||||
|
||||
final emailTile1Finder = find.byKey(Key('email_tile_builder_${EmailFixtures.email1.toPresentationEmail().id?.asString}'),);
|
||||
expect(emailTile1Finder, findsOneWidget);
|
||||
|
||||
@@ -461,9 +462,6 @@ void main() {
|
||||
final folder1ListViewEmailWidgetFinder = find.byKey(const PageStorageKey('list_presentation_email_in_threads'));
|
||||
expect(folder1ListViewEmailWidgetFinder, findsOneWidget);
|
||||
|
||||
final folder1ListViewEmailWidget = tester.widget<ListView>(folder1ListViewEmailWidgetFinder);
|
||||
expect(folder1ListViewEmailWidget.semanticChildCount, equals(listEmailsOfFolder1.length + 2));
|
||||
|
||||
final emailTile4Finder = find.byKey(Key('email_tile_builder_${EmailFixtures.email4.toPresentationEmail().id?.asString}'),);
|
||||
expect(emailTile4Finder, findsOneWidget);
|
||||
|
||||
@@ -531,9 +529,6 @@ void main() {
|
||||
final folder1ListViewEmailWidgetFinder = find.byKey(const PageStorageKey('list_presentation_email_in_threads'));
|
||||
expect(folder1ListViewEmailWidgetFinder, findsOneWidget);
|
||||
|
||||
final folder1ListViewEmailWidget = tester.widget<ListView>(folder1ListViewEmailWidgetFinder);
|
||||
expect(folder1ListViewEmailWidget.semanticChildCount, equals(listEmailsOfFolder1.length + 2));
|
||||
|
||||
final emailTile1Finder = find.byKey(Key('email_tile_builder_${EmailFixtures.email1.toPresentationEmail().id?.asString}'),);
|
||||
expect(emailTile1Finder, findsOneWidget);
|
||||
|
||||
@@ -581,10 +576,6 @@ void main() {
|
||||
final emptyEmailWidgetFinder = find.byKey(const Key('empty_thread_view'));
|
||||
expect(emptyEmailWidgetFinder, findsNothing);
|
||||
|
||||
final listViewEmailWidgetFinder = find.byKey(const PageStorageKey('list_presentation_email_in_threads'));
|
||||
final listViewEmailWidget = tester.widget<ListView>(listViewEmailWidgetFinder);
|
||||
expect(listViewEmailWidget.semanticChildCount, equals(listEmailsOfInbox.length + 2));
|
||||
|
||||
// Switch to mailbox Folder 1
|
||||
final listEmailsOfFolder1 = <PresentationEmail>[];
|
||||
mailboxDashboardController.setSelectedMailbox(MailboxFixtures.folder1.toPresentationMailbox());
|
||||
@@ -659,9 +650,6 @@ void main() {
|
||||
final listViewEmailWidgetFinder = find.byKey(const PageStorageKey('list_presentation_email_in_threads'));
|
||||
expect(listViewEmailWidgetFinder, findsOneWidget);
|
||||
|
||||
final listViewEmailWidget = tester.widget<ListView>(listViewEmailWidgetFinder);
|
||||
expect(listViewEmailWidget.semanticChildCount, equals(7));
|
||||
|
||||
expect(find.text('Load more'), findsOneWidget);
|
||||
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
@@ -705,9 +693,6 @@ void main() {
|
||||
final listViewEmailWidgetFinder = find.byKey(const PageStorageKey('list_presentation_email_in_threads'));
|
||||
expect(listViewEmailWidgetFinder, findsOneWidget);
|
||||
|
||||
final listViewEmailWidget = tester.widget<ListView>(listViewEmailWidgetFinder);
|
||||
expect(listViewEmailWidget.semanticChildCount, equals(5));
|
||||
|
||||
expect(find.text('Load more'), findsNothing);
|
||||
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
|
||||
@@ -66,6 +66,7 @@ import 'package:tmail_ui_user/features/thread/domain/model/email_filter.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/filter_message_option.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/state/refresh_changes_all_email_state.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/state/search_email_state.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/clean_and_get_emails_in_mailbox_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/empty_spam_folder_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/empty_trash_folder_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/get_email_by_id_interactor.dart';
|
||||
@@ -157,6 +158,7 @@ const fallbackGenerators = {
|
||||
MockSpec<RemoveComposerCacheByIdOnWebInteractor>(),
|
||||
MockSpec<GetAllIdentitiesInteractor>(),
|
||||
MockSpec<ComposerManager>(fallbackGenerators: fallbackGenerators),
|
||||
MockSpec<CleanAndGetEmailsInMailboxInteractor>(),
|
||||
])
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
@@ -169,6 +171,7 @@ void main() {
|
||||
late MockSearchEmailInteractor mockSearchEmailInteractor;
|
||||
late MockSearchMoreEmailInteractor mockSearchMoreEmailInteractor;
|
||||
late MockGetEmailByIdInteractor mockGetEmailByIdInteractor;
|
||||
late MockCleanAndGetEmailsInMailboxInteractor mockCleanAndGetEmailsInMailboxInteractor;
|
||||
|
||||
// Declaration search controller
|
||||
late SearchController searchController;
|
||||
@@ -275,6 +278,7 @@ void main() {
|
||||
mockSearchEmailInteractor = MockSearchEmailInteractor();
|
||||
mockSearchMoreEmailInteractor = MockSearchMoreEmailInteractor();
|
||||
mockGetEmailByIdInteractor = MockGetEmailByIdInteractor();
|
||||
mockCleanAndGetEmailsInMailboxInteractor = MockCleanAndGetEmailsInMailboxInteractor();
|
||||
|
||||
// Mock search controller
|
||||
mockQuickSearchEmailInteractor = MockQuickSearchEmailInteractor();
|
||||
@@ -366,6 +370,7 @@ void main() {
|
||||
mockSearchEmailInteractor,
|
||||
mockSearchMoreEmailInteractor,
|
||||
mockGetEmailByIdInteractor,
|
||||
mockCleanAndGetEmailsInMailboxInteractor,
|
||||
);
|
||||
|
||||
mailboxDashboardController.sessionCurrent = SessionFixtures.aliceSession;
|
||||
|
||||
@@ -37,6 +37,7 @@ import 'package:tmail_ui_user/features/thread/domain/model/filter_message_option
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/search_query.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/state/refresh_changes_all_email_state.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/state/search_email_state.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/clean_and_get_emails_in_mailbox_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/get_email_by_id_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/get_emails_in_mailbox_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/load_more_emails_in_mailbox_interactor.dart';
|
||||
@@ -87,6 +88,7 @@ const fallbackGenerators = {
|
||||
MockSpec<SearchEmailInteractor>(),
|
||||
MockSpec<SearchMoreEmailInteractor>(),
|
||||
MockSpec<GetEmailByIdInteractor>(),
|
||||
MockSpec<CleanAndGetEmailsInMailboxInteractor>(),
|
||||
])
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
@@ -102,6 +104,7 @@ void main() {
|
||||
late MockSearchEmailInteractor mockSearchEmailInteractor;
|
||||
late MockSearchMoreEmailInteractor mockSearchMoreEmailInteractor;
|
||||
late MockGetEmailByIdInteractor mockGetEmailByIdInteractor;
|
||||
late MockCleanAndGetEmailsInMailboxInteractor mockCleanAndGetEmailsInMailboxInteractor;
|
||||
|
||||
// Declaration base controller
|
||||
late MockCachingManager mockCachingManager;
|
||||
@@ -166,6 +169,7 @@ void main() {
|
||||
mockSearchEmailInteractor = MockSearchEmailInteractor();
|
||||
mockSearchMoreEmailInteractor = MockSearchMoreEmailInteractor();
|
||||
mockGetEmailByIdInteractor = MockGetEmailByIdInteractor();
|
||||
mockCleanAndGetEmailsInMailboxInteractor = MockCleanAndGetEmailsInMailboxInteractor();
|
||||
|
||||
Get.put<NetworkConnectionController>(mockNetworkConnectionController);
|
||||
Get.put<SearchController>(mockSearchController);
|
||||
@@ -177,7 +181,9 @@ void main() {
|
||||
mockLoadMoreEmailsInMailboxInteractor,
|
||||
mockSearchEmailInteractor,
|
||||
mockSearchMoreEmailInteractor,
|
||||
mockGetEmailByIdInteractor);
|
||||
mockGetEmailByIdInteractor,
|
||||
mockCleanAndGetEmailsInMailboxInteractor,
|
||||
);
|
||||
});
|
||||
|
||||
group('ThreadController::test', () {
|
||||
|
||||
Reference in New Issue
Block a user