Skip to content

Commit

Permalink
Apply OptionParamMixin for SearchEmailFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangdat committed Feb 28, 2024
1 parent c118aff commit 2b3de4c
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 24 deletions.
2 changes: 1 addition & 1 deletion contact/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dependencies:
jmap_dart_client:
git:
url: https://github.com/linagora/jmap-dart-client.git
ref: master
ref: cnb_support

### Dependencies from pub.dev ###
equatable: 2.0.5
Expand Down
2 changes: 1 addition & 1 deletion email_recovery/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:
jmap_dart_client:
git:
url: https://github.com/linagora/jmap-dart-client.git
ref: master
ref: cnb_support

### Dependencies from pub.dev ###
equatable: 2.0.5
Expand Down
2 changes: 1 addition & 1 deletion fcm/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:
jmap_dart_client:
git:
url: https://github.com/linagora/jmap-dart-client.git
ref: master
ref: cnb_support

### Dependencies from pub.dev ###
equatable: 2.0.5
Expand Down
2 changes: 1 addition & 1 deletion forward/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:
jmap_dart_client:
git:
url: https://github.com/linagora/jmap-dart-client.git
ref: master
ref: cnb_support

### Dependencies from pub.dev ###
equatable: 2.0.5
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:core/core.dart';
import 'package:dartz/dartz.dart';
import 'package:equatable/equatable.dart';
import 'package:jmap_dart_client/jmap/core/filter/filter.dart';
Expand All @@ -13,7 +14,7 @@ import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/model/sear
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/model/search/email_sort_order_type.dart';
import 'package:tmail_ui_user/features/thread/domain/model/search_query.dart';

class SearchEmailFilter with EquatableMixin {
class SearchEmailFilter with EquatableMixin, OptionParamMixin {
final Set<String> from;
final Set<String> to;
final SearchQuery? text;
Expand Down Expand Up @@ -69,30 +70,22 @@ class SearchEmailFilter with EquatableMixin {
Option<int>? positionOption,
}) {
return SearchEmailFilter(
from: _getOptionParam(fromOption, from),
to: _getOptionParam(toOption, to),
from: getOptionParam(fromOption, from),
to: getOptionParam(toOption, to),
text: text ?? this.text,
subject: _getOptionParam(subjectOption, subject),
subject: getOptionParam(subjectOption, subject),
notKeyword: notKeyword ?? this.notKeyword,
mailbox: mailbox ?? this.mailbox,
emailReceiveTimeType: emailReceiveTimeType ?? this.emailReceiveTimeType,
hasAttachment: hasAttachment ?? this.hasAttachment,
before: _getOptionParam(beforeOption, before),
startDate: _getOptionParam(startDateOption, startDate),
endDate: _getOptionParam(endDateOption, endDate),
sortOrder: _getOptionParam(sortOrderOption, sortOrder),
position: _getOptionParam(positionOption, position),
before: getOptionParam(beforeOption, before),
startDate: getOptionParam(startDateOption, startDate),
endDate: getOptionParam(endDateOption, endDate),
sortOrder: getOptionParam(sortOrderOption, sortOrder),
position: getOptionParam(positionOption, position),
);
}

T? _getOptionParam<T>(Option<T?>? option, T? defaultValue) {
if (option != null) {
return option.toNullable();
} else {
return defaultValue;
}
}

Filter? mappingToEmailFilterCondition({
required EmailSortOrderType sortOrderType,
EmailFilterCondition? moreFilterCondition
Expand Down
2 changes: 1 addition & 1 deletion model/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies:
jmap_dart_client:
git:
url: https://github.com/linagora/jmap-dart-client.git
ref: master
ref: cnb_support

### Dependencies from pub.dev ###
cupertino_icons: 1.0.6
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ dependencies:
jmap_dart_client:
git:
url: https://github.com/linagora/jmap-dart-client.git
ref: master
ref: cnb_support

contacts_service:
git:
Expand Down
2 changes: 1 addition & 1 deletion rule_filter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:
jmap_dart_client:
git:
url: https://github.com/linagora/jmap-dart-client.git
ref: master
ref: cnb_support

### Dependencies from pub.dev ###
equatable: 2.0.5
Expand Down

0 comments on commit 2b3de4c

Please sign in to comment.