bc0f6a4ac6
* Add `Events` filter checkbox in Advanced Search form * Perform search email by `Events` filter in Advanced Search form * Add `Event` quick search button in Search view * Use `keywords` replace to `headers` for search event filter
35 lines
1.3 KiB
Dart
35 lines
1.3 KiB
Dart
import 'package:jmap_dart_client/jmap/core/patch_object.dart';
|
|
import 'package:jmap_dart_client/jmap/mail/email/keyword_identifier.dart';
|
|
import 'package:model/email/mark_star_action.dart';
|
|
import 'package:model/email/read_actions.dart';
|
|
|
|
extension KeyWordIdentifierExtension on KeyWordIdentifier {
|
|
static final unsubscribeMail = KeyWordIdentifier('\$unsubscribe');
|
|
static final needsActionMail = KeyWordIdentifier('needs-action');
|
|
static final eventsMail = KeyWordIdentifier('event');
|
|
|
|
String generatePath() => '${PatchObject.keywordsProperty}/$value';
|
|
|
|
/// General helper to generate a boolean patch.
|
|
PatchObject _boolPatch(bool? flag) {
|
|
return PatchObject({generatePath(): flag});
|
|
}
|
|
|
|
PatchObject generateReadActionPath(ReadActions action) {
|
|
return _boolPatch(action == ReadActions.markAsRead ? true : null);
|
|
}
|
|
|
|
PatchObject generateMarkStarActionPath(MarkStarAction action) {
|
|
return _boolPatch(action == MarkStarAction.markStar ? true : null);
|
|
}
|
|
|
|
PatchObject generateAnsweredActionPath() => _boolPatch(true);
|
|
|
|
PatchObject generateForwardedActionPath() => _boolPatch(true);
|
|
|
|
PatchObject generateUnsubscribeActionPath() => _boolPatch(true);
|
|
|
|
PatchObject generateLabelActionPath({bool remove = false}) =>
|
|
_boolPatch(remove ? null : true);
|
|
}
|