TF-1715 Disable Starred option in filter message in context menu
This commit is contained in:
@@ -30,6 +30,7 @@ class CleanAndGetEmailsInMailboxInteractor {
|
|||||||
Properties? propertiesCreated,
|
Properties? propertiesCreated,
|
||||||
Properties? propertiesUpdated,
|
Properties? propertiesUpdated,
|
||||||
bool getLatestChanges = true,
|
bool getLatestChanges = true,
|
||||||
|
bool useCache = true,
|
||||||
}
|
}
|
||||||
) async* {
|
) async* {
|
||||||
try {
|
try {
|
||||||
@@ -46,6 +47,7 @@ class CleanAndGetEmailsInMailboxInteractor {
|
|||||||
propertiesCreated: propertiesCreated,
|
propertiesCreated: propertiesCreated,
|
||||||
propertiesUpdated: propertiesUpdated,
|
propertiesUpdated: propertiesUpdated,
|
||||||
getLatestChanges: getLatestChanges,
|
getLatestChanges: getLatestChanges,
|
||||||
|
useCache: useCache,
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
yield Left(CleanAndGetAllEmailFailure(e));
|
yield Left(CleanAndGetAllEmailFailure(e));
|
||||||
|
|||||||
+3
-1
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:model/extensions/mailbox_id_extension.dart';
|
||||||
import 'package:tmail_ui_user/features/base/widget/popup_menu/popup_menu_item_action_widget.dart';
|
import 'package:tmail_ui_user/features/base/widget/popup_menu/popup_menu_item_action_widget.dart';
|
||||||
import 'package:tmail_ui_user/features/thread/domain/model/filter_message_option.dart';
|
import 'package:tmail_ui_user/features/thread/domain/model/filter_message_option.dart';
|
||||||
import 'package:tmail_ui_user/features/thread/presentation/model/popup_menu_item_filter_message_action.dart';
|
import 'package:tmail_ui_user/features/thread/presentation/model/popup_menu_item_filter_message_action.dart';
|
||||||
@@ -15,7 +16,8 @@ extension HandleOpenContextMenuFilterEmailActionExtension on ThreadController {
|
|||||||
final popupMenuItems = [
|
final popupMenuItems = [
|
||||||
FilterMessageOption.attachments,
|
FilterMessageOption.attachments,
|
||||||
FilterMessageOption.unread,
|
FilterMessageOption.unread,
|
||||||
FilterMessageOption.starred,
|
if (selectedMailboxId?.isFavoriteMailboxId != true)
|
||||||
|
FilterMessageOption.starred,
|
||||||
].map((filterOption) {
|
].map((filterOption) {
|
||||||
return PopupMenuItem(
|
return PopupMenuItem(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
|
|||||||
+3
-6
@@ -1,11 +1,11 @@
|
|||||||
|
|
||||||
import 'package:core/utils/app_logger.dart';
|
import 'package:core/utils/app_logger.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
|
import 'package:model/extensions/mailbox_id_extension.dart';
|
||||||
import 'package:tmail_ui_user/features/email/presentation/utils/email_utils.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/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/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/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/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_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/model/loading_more_status.dart';
|
||||||
@@ -42,17 +42,14 @@ extension HandlePullToRefreshListEmailExtension on ThreadController {
|
|||||||
accountId,
|
accountId,
|
||||||
limit: ThreadConstants.defaultLimit,
|
limit: ThreadConstants.defaultLimit,
|
||||||
sort: EmailSortOrderType.mostRecent.getSortOrder().toNullable(),
|
sort: EmailSortOrderType.mostRecent.getSortOrder().toNullable(),
|
||||||
emailFilter: EmailFilter(
|
emailFilter: getEmailFilterForLoadMailbox(),
|
||||||
filter: getFilterCondition(mailboxIdSelected: selectedMailboxId),
|
|
||||||
filterOption: mailboxDashBoardController.filterMessageOption.value,
|
|
||||||
mailboxId: selectedMailboxId,
|
|
||||||
),
|
|
||||||
propertiesCreated: EmailUtils.getPropertiesForEmailGetMethod(session, accountId),
|
propertiesCreated: EmailUtils.getPropertiesForEmailGetMethod(session, accountId),
|
||||||
propertiesUpdated: EmailUtils.getPropertiesForEmailChangeMethod(
|
propertiesUpdated: EmailUtils.getPropertiesForEmailChangeMethod(
|
||||||
session,
|
session,
|
||||||
accountId,
|
accountId,
|
||||||
),
|
),
|
||||||
getLatestChanges: true,
|
getLatestChanges: true,
|
||||||
|
useCache: selectedMailboxId?.isFavoriteMailboxId != true,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-1
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:model/extensions/mailbox_id_extension.dart';
|
||||||
import 'package:tmail_ui_user/features/thread/domain/model/filter_message_option.dart';
|
import 'package:tmail_ui_user/features/thread/domain/model/filter_message_option.dart';
|
||||||
import 'package:tmail_ui_user/features/thread/presentation/model/context_item_filter_message_option_action.dart';
|
import 'package:tmail_ui_user/features/thread/presentation/model/context_item_filter_message_option_action.dart';
|
||||||
import 'package:tmail_ui_user/features/thread/presentation/thread_controller.dart';
|
import 'package:tmail_ui_user/features/thread/presentation/thread_controller.dart';
|
||||||
@@ -13,7 +14,8 @@ extension HandleSelectMessageFilterExtension on ThreadController {
|
|||||||
final contextMenuActions = [
|
final contextMenuActions = [
|
||||||
FilterMessageOption.attachments,
|
FilterMessageOption.attachments,
|
||||||
FilterMessageOption.unread,
|
FilterMessageOption.unread,
|
||||||
FilterMessageOption.starred,
|
if (selectedMailboxId?.isFavoriteMailboxId != true)
|
||||||
|
FilterMessageOption.starred,
|
||||||
].map((filter) {
|
].map((filter) {
|
||||||
return ContextItemFilterMessageOptionAction(
|
return ContextItemFilterMessageOptionAction(
|
||||||
filter,
|
filter,
|
||||||
|
|||||||
@@ -507,7 +507,7 @@ class ThreadController extends BaseController with EmailActionController {
|
|||||||
mailboxDashBoardController.updateRefreshAllEmailState(Right(RefreshAllEmailSuccess()));
|
mailboxDashBoardController.updateRefreshAllEmailState(Right(RefreshAllEmailSuccess()));
|
||||||
|
|
||||||
if (success.currentMailboxId != selectedMailboxId &&
|
if (success.currentMailboxId != selectedMailboxId &&
|
||||||
selectedMailboxId?.isNotFavoriteMailboxId == true) {
|
selectedMailboxId?.isFavoriteMailboxId != true) {
|
||||||
log('ThreadController::_getAllEmailSuccess: GetAllForMailboxId = ${success.currentMailboxId?.asString} | SELECTED_MAILBOX_ID = ${selectedMailboxId?.asString} | SELECTED_MAILBOX_NAME = ${selectedMailbox?.name?.name}');
|
log('ThreadController::_getAllEmailSuccess: GetAllForMailboxId = ${success.currentMailboxId?.asString} | SELECTED_MAILBOX_ID = ${selectedMailboxId?.asString} | SELECTED_MAILBOX_NAME = ${selectedMailbox?.name?.name}');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -548,7 +548,7 @@ class ThreadController extends BaseController with EmailActionController {
|
|||||||
|
|
||||||
void _refreshChangesAllEmailSuccess(RefreshChangesAllEmailSuccess success) {
|
void _refreshChangesAllEmailSuccess(RefreshChangesAllEmailSuccess success) {
|
||||||
if (success.currentMailboxId != selectedMailboxId &&
|
if (success.currentMailboxId != selectedMailboxId &&
|
||||||
selectedMailboxId?.isNotFavoriteMailboxId == true) {
|
selectedMailboxId?.isFavoriteMailboxId != true) {
|
||||||
log('ThreadController::_refreshChangesAllEmailSuccess: RefreshedMailboxId = ${success.currentMailboxId?.asString} | SELECTED_MAILBOX_ID = ${selectedMailboxId?.asString} | SELECTED_MAILBOX_NAME = ${selectedMailbox?.name?.name}');
|
log('ThreadController::_refreshChangesAllEmailSuccess: RefreshedMailboxId = ${success.currentMailboxId?.asString} | SELECTED_MAILBOX_ID = ${selectedMailboxId?.asString} | SELECTED_MAILBOX_NAME = ${selectedMailbox?.name?.name}');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -584,41 +584,55 @@ class ThreadController extends BaseController with EmailActionController {
|
|||||||
_accountId!,
|
_accountId!,
|
||||||
limit: ThreadConstants.defaultLimit,
|
limit: ThreadConstants.defaultLimit,
|
||||||
sort: EmailSortOrderType.mostRecent.getSortOrder().toNullable(),
|
sort: EmailSortOrderType.mostRecent.getSortOrder().toNullable(),
|
||||||
emailFilter: _getEmailFilterForLoadMailbox(),
|
emailFilter: getEmailFilterForLoadMailbox(),
|
||||||
propertiesCreated: EmailUtils.getPropertiesForEmailGetMethod(_session!, _accountId!),
|
propertiesCreated: EmailUtils.getPropertiesForEmailGetMethod(_session!, _accountId!),
|
||||||
propertiesUpdated: EmailUtils.getPropertiesForEmailChangeMethod(
|
propertiesUpdated: EmailUtils.getPropertiesForEmailChangeMethod(
|
||||||
_session!,
|
_session!,
|
||||||
_accountId!,
|
_accountId!,
|
||||||
),
|
),
|
||||||
getLatestChanges: getLatestChanges,
|
getLatestChanges: getLatestChanges,
|
||||||
useCache: selectedMailboxId?.isNotFavoriteMailboxId == true,
|
useCache: selectedMailboxId?.isFavoriteMailboxId != true,
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
consumeState(Stream.value(Left(GetAllEmailFailure(NotFoundSessionException()))));
|
consumeState(Stream.value(Left(GetAllEmailFailure(NotFoundSessionException()))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EmailFilter _getEmailFilterForLoadMailbox({PresentationEmail? oldestEmail}) {
|
EmailFilter getEmailFilterForLoadMailbox({PresentationEmail? oldestEmail}) {
|
||||||
if (selectedMailboxId?.isNotFavoriteMailboxId != true) {
|
if (selectedMailboxId?.isFavoriteMailboxId == true) {
|
||||||
return EmailFilter(
|
return EmailFilter(
|
||||||
filter: _getFilterConditionForLoadMailbox(oldestEmail: oldestEmail),
|
filter: getFilterConditionForLoadMailbox(oldestEmail: oldestEmail),
|
||||||
filterOption: mailboxDashBoardController.filterMessageOption.value,
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return EmailFilter(
|
return EmailFilter(
|
||||||
filter: _getFilterConditionForLoadMailbox(oldestEmail: oldestEmail),
|
filter: getFilterConditionForLoadMailbox(oldestEmail: oldestEmail),
|
||||||
filterOption: mailboxDashBoardController.filterMessageOption.value,
|
filterOption: mailboxDashBoardController.filterMessageOption.value,
|
||||||
mailboxId: selectedMailboxId,
|
mailboxId: selectedMailboxId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Filter _getFilterConditionForLoadMailbox({PresentationEmail? oldestEmail}) {
|
Filter getFilterConditionForLoadMailbox({PresentationEmail? oldestEmail}) {
|
||||||
if (selectedMailboxId?.isNotFavoriteMailboxId != true) {
|
if (selectedMailboxId?.isFavoriteMailboxId == true) {
|
||||||
return EmailFilterCondition(
|
switch (mailboxDashBoardController.filterMessageOption.value) {
|
||||||
hasKeyword: KeyWordIdentifier.emailFlagged.value,
|
case FilterMessageOption.unread:
|
||||||
before: oldestEmail?.receivedAt,
|
return EmailFilterCondition(
|
||||||
);
|
notKeyword: KeyWordIdentifier.emailSeen.value,
|
||||||
|
hasKeyword: KeyWordIdentifier.emailFlagged.value,
|
||||||
|
before: oldestEmail?.receivedAt,
|
||||||
|
);
|
||||||
|
case FilterMessageOption.attachments:
|
||||||
|
return EmailFilterCondition(
|
||||||
|
hasAttachment: true,
|
||||||
|
hasKeyword: KeyWordIdentifier.emailFlagged.value,
|
||||||
|
before: oldestEmail?.receivedAt,
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
return EmailFilterCondition(
|
||||||
|
hasKeyword: KeyWordIdentifier.emailFlagged.value,
|
||||||
|
before: oldestEmail?.receivedAt,
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return getFilterCondition(
|
return getFilterCondition(
|
||||||
mailboxIdSelected: selectedMailboxId,
|
mailboxIdSelected: selectedMailboxId,
|
||||||
@@ -772,7 +786,7 @@ class ThreadController extends BaseController with EmailActionController {
|
|||||||
_session!,
|
_session!,
|
||||||
_accountId!,
|
_accountId!,
|
||||||
),
|
),
|
||||||
emailFilter: _getEmailFilterForLoadMailbox(),
|
emailFilter: getEmailFilterForLoadMailbox(),
|
||||||
).last;
|
).last;
|
||||||
|
|
||||||
refreshState.fold(
|
refreshState.fold(
|
||||||
@@ -815,17 +829,17 @@ class ThreadController extends BaseController with EmailActionController {
|
|||||||
limit: ThreadConstants.defaultLimit,
|
limit: ThreadConstants.defaultLimit,
|
||||||
sort: EmailSortOrderType.mostRecent.getSortOrder().toNullable(),
|
sort: EmailSortOrderType.mostRecent.getSortOrder().toNullable(),
|
||||||
filterOption: mailboxDashBoardController.filterMessageOption.value,
|
filterOption: mailboxDashBoardController.filterMessageOption.value,
|
||||||
filter: _getFilterConditionForLoadMailbox(oldestEmail: oldestEmail),
|
filter: getFilterConditionForLoadMailbox(oldestEmail: oldestEmail),
|
||||||
properties: EmailUtils.getPropertiesForEmailGetMethod(_session!, _accountId!),
|
properties: EmailUtils.getPropertiesForEmailGetMethod(_session!, _accountId!),
|
||||||
lastEmailId: oldestEmail?.id,
|
lastEmailId: oldestEmail?.id,
|
||||||
useCache: selectedMailboxId?.isNotFavoriteMailboxId == true,
|
useCache: selectedMailboxId?.isFavoriteMailboxId != true,
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _validatePresentationEmail(PresentationEmail email) {
|
bool _validatePresentationEmail(PresentationEmail email) {
|
||||||
return (_belongToCurrentMailboxId(email) || selectedMailboxId?.isNotFavoriteMailboxId != true)
|
return (_belongToCurrentMailboxId(email) || selectedMailboxId?.isFavoriteMailboxId == true)
|
||||||
&& _notDuplicatedInCurrentList(email);
|
&& _notDuplicatedInCurrentList(email);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,6 @@ extension MailboxIdExtension on MailboxId {
|
|||||||
|
|
||||||
String get asString => id.value;
|
String get asString => id.value;
|
||||||
|
|
||||||
bool get isNotFavoriteMailboxId =>
|
bool get isFavoriteMailboxId =>
|
||||||
this != PresentationMailbox.favoriteFolder.id;
|
this == PresentationMailbox.favoriteFolder.id;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user