TF-3698 Thread Detail Real time update

TF-3698 Thread Detail update reset RefreshThreadDetailAction position

TF-3698 Thread Detail refactor initializeThreadDetailEmails

TF-3698 Thread Detail refactor handleRefreshThreadDetailAction

TF-3698 Thread Detail create listThreadIds in ListEmailExtension
This commit is contained in:
DatDang
2025-05-27 11:03:28 +07:00
committed by Dat H. Pham
parent 1bc45e35f3
commit d210a892f2
28 changed files with 647 additions and 83 deletions
@@ -10,8 +10,9 @@ abstract class ThreadDetailRepository {
Session session,
AccountId accountId,
MailboxId sentMailboxId,
String ownEmailAddress,
);
String ownEmailAddress, {
required EmailId? selectedEmailId,
});
Future<List<Email>> getEmailsByIds(
Session session,
@@ -12,14 +12,27 @@ class GettingEmailsByIds extends LoadingState {
}
class GetEmailsByIdsSuccess extends UIState {
GetEmailsByIdsSuccess(this.presentationEmails);
GetEmailsByIdsSuccess(
this.presentationEmails, {
this.updateCurrentThreadDetail = false,
});
final List<PresentationEmail> presentationEmails;
final bool updateCurrentThreadDetail;
@override
List<Object?> get props => [presentationEmails];
List<Object?> get props => [presentationEmails, updateCurrentThreadDetail];
}
class GetEmailsByIdsFailure extends FeatureFailure {
GetEmailsByIdsFailure({super.exception, super.onRetry});
GetEmailsByIdsFailure({
super.exception,
super.onRetry,
required this.updateCurrentThreadDetail,
});
final bool updateCurrentThreadDetail;
@override
List<Object?> get props => [...super.props, updateCurrentThreadDetail];
}
@@ -2,17 +2,34 @@ import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart';
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
class GettingThreadById extends LoadingState {}
class GettingThreadById extends LoadingState {
final bool updateCurrentThreadDetail;
GettingThreadById({this.updateCurrentThreadDetail = false});
@override
List<Object> get props => [updateCurrentThreadDetail];
}
class GetThreadByIdSuccess extends UIState {
final List<EmailId> emailIds;
final bool updateCurrentThreadDetail;
GetThreadByIdSuccess(this.emailIds);
GetThreadByIdSuccess(this.emailIds, {this.updateCurrentThreadDetail = false});
@override
List<Object> get props => [emailIds];
List<Object> get props => [emailIds, updateCurrentThreadDetail];
}
class GetThreadByIdFailure extends FeatureFailure {
GetThreadByIdFailure({super.exception, super.onRetry});
GetThreadByIdFailure({
super.exception,
super.onRetry,
required this.updateCurrentThreadDetail,
});
final bool updateCurrentThreadDetail;
@override
List<Object?> get props => [...super.props, updateCurrentThreadDetail];
}
@@ -23,6 +23,7 @@ class GetEmailsByIdsInteractor {
List<EmailId> emailIds, {
Properties? properties,
int? loadMoreIndex,
bool updateCurrentThreadDetail = false,
}) async* {
try {
if (emailIds.length > 1 && (
@@ -41,12 +42,14 @@ class GetEmailsByIdsInteractor {
);
yield Right(GetEmailsByIdsSuccess(
result.map((e) => e.toPresentationEmail()).toList(),
updateCurrentThreadDetail: updateCurrentThreadDetail,
));
} catch (e) {
logError('GetEmailsByIdsInteractor::execute(): Exception: $e');
yield Left(GetEmailsByIdsFailure(
exception: e,
onRetry: execute(session, accountId, emailIds, properties: properties),
updateCurrentThreadDetail: updateCurrentThreadDetail,
));
}
}
@@ -19,19 +19,27 @@ class GetThreadByIdInteractor {
Session session,
AccountId accountId,
MailboxId sentMailboxId,
String ownEmailAddress,
) async* {
String ownEmailAddress, {
required EmailId? selectedEmailId,
bool updateCurrentThreadDetail = false,
}) async* {
try {
yield Right(GettingThreadById());
yield Right(GettingThreadById(
updateCurrentThreadDetail: updateCurrentThreadDetail,
));
final result = await _threadDetailRepository.getThreadById(
threadId,
session,
accountId,
sentMailboxId,
ownEmailAddress,
selectedEmailId: selectedEmailId,
);
yield Right(GetThreadByIdSuccess(result));
yield Right(GetThreadByIdSuccess(
result,
updateCurrentThreadDetail: updateCurrentThreadDetail,
));
} catch (e) {
logError('GetEmailIdsByThreadIdInteractor::execute(): Exception: $e');
yield Left(GetThreadByIdFailure(
@@ -42,7 +50,9 @@ class GetThreadByIdInteractor {
accountId,
sentMailboxId,
ownEmailAddress,
selectedEmailId: selectedEmailId,
),
updateCurrentThreadDetail: updateCurrentThreadDetail,
));
}
}