TF-3385 Update mark as read and star
This commit is contained in:
+56
@@ -0,0 +1,56 @@
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/keyword_identifier.dart';
|
||||
import 'package:model/email/mark_star_action.dart';
|
||||
import 'package:model/email/presentation_email.dart';
|
||||
import 'package:model/email/read_actions.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart';
|
||||
|
||||
extension UpdateCurrentEmailsFlagsExtension on MailboxDashBoardController {
|
||||
void updateEmailFlagByEmailIds(
|
||||
List<EmailId> emailIds, {
|
||||
ReadActions? readAction,
|
||||
MarkStarAction? markStarAction,
|
||||
}) {
|
||||
if (readAction == null && markStarAction == null) return;
|
||||
|
||||
for (var email in emailsInCurrentMailbox) {
|
||||
if (!emailIds.contains(email.id)) continue;
|
||||
|
||||
switch (readAction) {
|
||||
case ReadActions.markAsRead:
|
||||
_updateKeyword(email, KeyWordIdentifier.emailSeen, true);
|
||||
break;
|
||||
case ReadActions.markAsUnread:
|
||||
_updateKeyword(email, KeyWordIdentifier.emailSeen, false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (markStarAction) {
|
||||
case MarkStarAction.markStar:
|
||||
_updateKeyword(email, KeyWordIdentifier.emailFlagged, true);
|
||||
break;
|
||||
case MarkStarAction.unMarkStar:
|
||||
_updateKeyword(email, KeyWordIdentifier.emailFlagged, false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
emailsInCurrentMailbox.refresh();
|
||||
}
|
||||
|
||||
void _updateKeyword(
|
||||
PresentationEmail presentationEmail,
|
||||
KeyWordIdentifier keyword,
|
||||
bool value,
|
||||
) {
|
||||
if (value) {
|
||||
presentationEmail.keywords?[keyword] = true;
|
||||
} else {
|
||||
presentationEmail.keywords?.remove(keyword);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user