TF-332 Add loadingState for update email drafts and get content email
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
|
||||
class UpdatingEmailDrafts extends UIState {
|
||||
|
||||
UpdatingEmailDrafts();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class UpdateEmailDraftsSuccess extends UIState {
|
||||
|
||||
final Email emailAsDrafts;
|
||||
|
||||
@@ -12,6 +12,7 @@ class UpdateEmailDraftsInteractor {
|
||||
|
||||
Stream<Either<Failure, Success>> execute(AccountId accountId, Email newEmail, EmailId oldEmailId) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(UpdatingEmailDrafts());
|
||||
final newEmailDrafts = await emailRepository.updateEmailDrafts(accountId, newEmail, oldEmailId);
|
||||
if (newEmailDrafts != null) {
|
||||
yield Right<Failure, Success>(UpdateEmailDraftsSuccess(newEmailDrafts));
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
class GetEmailContentLoading extends UIState {
|
||||
|
||||
GetEmailContentLoading();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class GetEmailContentSuccess extends UIState {
|
||||
final List<EmailContent> emailContents;
|
||||
final List<EmailContent> emailContentsDisplayed;
|
||||
@@ -13,7 +21,7 @@ class GetEmailContentSuccess extends UIState {
|
||||
}
|
||||
|
||||
class GetEmailContentFailure extends FeatureFailure {
|
||||
final exception;
|
||||
final dynamic exception;
|
||||
|
||||
GetEmailContentFailure(this.exception);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ class GetEmailContentInteractor {
|
||||
|
||||
Stream<Either<Failure, Success>> execute(AccountId accountId, EmailId emailId, String? baseDownloadUrl) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(LoadingState());
|
||||
yield Right<Failure, Success>(GetEmailContentLoading());
|
||||
final email = await emailRepository.getEmailContent(accountId, emailId);
|
||||
|
||||
if (email.emailContentList.isNotEmpty) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||
import 'package:model/model.dart';
|
||||
import 'package:tmail_ui_user/features/base/mixin/network_connection_mixin.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/extensions/prefix_email_address_extension.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/get_email_content_state.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/email_controller.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/app_bar_mail_widget_builder.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/attachment_file_tile_builder.dart';
|
||||
@@ -226,7 +227,7 @@ class EmailView extends GetWidget<EmailController> with NetworkConnectionMixin {
|
||||
return controller.viewState.value.fold(
|
||||
(failure) => const SizedBox.shrink(),
|
||||
(success) {
|
||||
if (success is LoadingState) {
|
||||
if (success is GetEmailContentLoading) {
|
||||
return const Align(alignment: Alignment.topCenter, child: Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: SizedBox(
|
||||
|
||||
Reference in New Issue
Block a user