TF-1706 Fix grey bar on server CYRUS
(cherry picked from commit 3ae632c967607cd84ddd79da8d9e17421f6b31ff)
This commit is contained in:
@@ -1459,7 +1459,7 @@ class ComposerController extends BaseController {
|
||||
final arguments = composerArguments.value;
|
||||
if (arguments != null) {
|
||||
if (arguments.emailActionType == EmailActionType.editDraft) {
|
||||
return arguments.presentationEmail?.from?.first.emailAddress ?? '';
|
||||
return arguments.presentationEmail?.firstEmailAddressInFrom ?? '';
|
||||
} else {
|
||||
return mailboxDashBoardController.userProfile.value?.email ?? '';
|
||||
}
|
||||
|
||||
@@ -454,7 +454,8 @@ class EmailView extends GetWidget<SingleEmailController> {
|
||||
return <Widget>[
|
||||
_markAsEmailUnreadAction(context, email),
|
||||
_markAsEmailSpamOrUnSpamAction(context, email),
|
||||
_quickCreatingRuleAction(context, email),
|
||||
if (email.from?.isNotEmpty == true)
|
||||
_quickCreatingRuleAction(context, email),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -567,7 +568,8 @@ class EmailView extends GetWidget<SingleEmailController> {
|
||||
return [
|
||||
_markAsEmailUnreadPopupItemAction(context, email),
|
||||
_markAsEmailSpamOrUnSpamPopupItemAction(context, email, mailboxContain),
|
||||
_quickCreatingRulePopupItemAction(context, email)
|
||||
if (email.from?.isNotEmpty == true)
|
||||
_quickCreatingRulePopupItemAction(context, email)
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ class EmailChangeListener extends ChangeListener {
|
||||
id: presentationEmail.id?.id.value ?? '',
|
||||
title: presentationEmail.subject ?? '',
|
||||
message: presentationEmail.preview,
|
||||
emailAddress: presentationEmail.from?.first,
|
||||
emailAddress: presentationEmail.firstFromAddress,
|
||||
payload: notificationPayload.encodeToString,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -73,6 +73,22 @@ class PresentationEmail with EquatableMixin {
|
||||
}
|
||||
}
|
||||
|
||||
String get firstEmailAddressInFrom {
|
||||
if (from?.isNotEmpty == true) {
|
||||
return from!.first.emailAddress;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
EmailAddress? get firstFromAddress {
|
||||
if (from?.isNotEmpty == true) {
|
||||
return from!.first;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
String getAvatarText() {
|
||||
if (getSenderName().isNotEmpty) {
|
||||
return getSenderName().firstLetterToUpperCase;
|
||||
|
||||
@@ -19,7 +19,11 @@ import 'package:model/mailbox/select_mode.dart';
|
||||
extension PresentationEmailExtension on PresentationEmail {
|
||||
|
||||
List<Color> get avatarColors {
|
||||
return from?.first.avatarColors ?? AppColor.mapGradientColor.first;
|
||||
if (from?.isNotEmpty == true) {
|
||||
return from!.first.avatarColors;
|
||||
} else {
|
||||
return AppColor.mapGradientColor.first;
|
||||
}
|
||||
}
|
||||
|
||||
int numberOfAllEmailAddress() => to.numberEmailAddress() + cc.numberEmailAddress() + bcc.numberEmailAddress();
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:model/extensions/presentation_email_extension.dart';
|
||||
|
||||
import '../../fixtures/email_fixtures.dart';
|
||||
|
||||
void main() {
|
||||
|
||||
group('avatar_email test', () {
|
||||
test('presentationEmail.avatarColors should return list color when `From` email is NotNull and NotEmpty', () {
|
||||
final listColors = EmailFixtures.presentationEmailWithFromIsNotNull.avatarColors;
|
||||
|
||||
expect(listColors.length, equals(2));
|
||||
});
|
||||
|
||||
test('presentationEmail.avatarColors should return list default color when `From` email is Null', () {
|
||||
final listColors = EmailFixtures.presentationEmailWithFromIsNull.avatarColors;
|
||||
|
||||
expect(listColors, containsAll(AppColor.mapGradientColor.first));
|
||||
expect(listColors.length, equals(2));
|
||||
});
|
||||
|
||||
test('presentationEmail.avatarColors should return list default color when `From` email is Empty', () {
|
||||
final listColors = EmailFixtures.presentationEmailWithFromIsEmpty.avatarColors;
|
||||
|
||||
expect(listColors, containsAll(AppColor.mapGradientColor.first));
|
||||
expect(listColors.length, equals(2));
|
||||
});
|
||||
});
|
||||
}
|
||||
Vendored
+36
@@ -3,6 +3,7 @@ import 'package:jmap_dart_client/jmap/core/utc_date.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/keyword_identifier.dart';
|
||||
import 'package:model/email/presentation_email.dart';
|
||||
|
||||
import 'mailbox_fixtures.dart';
|
||||
|
||||
@@ -70,4 +71,39 @@ class EmailFixtures {
|
||||
mailboxIds: {MailboxFixtures.inboxMailbox.id! : true},
|
||||
to: {EmailAddress("DatVu", "tdvu@yahoo.com")},
|
||||
);
|
||||
|
||||
static final presentationEmailWithFromIsNotNull = PresentationEmail(
|
||||
id: EmailId(Id("382312d0-fa5c-11eb-b647-2fef1ee98e0d")),
|
||||
preview: "Have a from and to address",
|
||||
hasAttachment: false,
|
||||
subject: "test avatar",
|
||||
from: {EmailAddress("DatVu", "tdvu@linagora.com")},
|
||||
sentAt: UTCDate(DateTime.parse("2021-08-11T04:25:34Z")),
|
||||
receivedAt: UTCDate(DateTime.parse("2021-08-11T04:25:55Z")),
|
||||
keywords: {KeyWordIdentifier.emailSeen : true},
|
||||
mailboxIds: {MailboxFixtures.inboxMailbox.id! : true},
|
||||
);
|
||||
|
||||
static final presentationEmailWithFromIsNull = PresentationEmail(
|
||||
id: EmailId(Id("382312d0-fa5c-11eb-b647-2fef1ee98f9d")),
|
||||
preview: "Not have a from and to address",
|
||||
hasAttachment: false,
|
||||
subject: "test avatar",
|
||||
sentAt: UTCDate(DateTime.parse("2021-08-11T04:25:34Z")),
|
||||
receivedAt: UTCDate(DateTime.parse("2021-08-11T04:25:55Z")),
|
||||
keywords: {KeyWordIdentifier.emailSeen : true},
|
||||
mailboxIds: {MailboxFixtures.inboxMailbox.id! : true}
|
||||
);
|
||||
|
||||
static final presentationEmailWithFromIsEmpty = PresentationEmail(
|
||||
id: EmailId(Id("382312d0-fa5c-11eb-b647-2fef1ee98f9e")),
|
||||
preview: "Not have a from and to address",
|
||||
hasAttachment: false,
|
||||
subject: "test avatar",
|
||||
from: {},
|
||||
sentAt: UTCDate(DateTime.parse("2021-08-11T04:25:34Z")),
|
||||
receivedAt: UTCDate(DateTime.parse("2021-08-11T04:25:55Z")),
|
||||
keywords: {KeyWordIdentifier.emailSeen : true},
|
||||
mailboxIds: {MailboxFixtures.inboxMailbox.id! : true}
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user