TF-79 Mark as star/unstar in email detailed view
This commit is contained in:
@@ -29,4 +29,6 @@ abstract class EmailDataSource {
|
||||
);
|
||||
|
||||
Future<List<EmailId>> moveToMailbox(AccountId accountId, MoveRequest moveRequest);
|
||||
|
||||
Future<bool> markAsImportant(AccountId accountId, EmailId emailId, ImportantAction importantAction);
|
||||
}
|
||||
@@ -77,4 +77,13 @@ class EmailDataSourceImpl extends EmailDataSource {
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> markAsImportant(AccountId accountId, EmailId emailId, ImportantAction importantAction) {
|
||||
return Future.sync(() async {
|
||||
return await emailAPI.markAsImportant(accountId, emailId, importantAction);
|
||||
}).catchError((error) {
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -219,4 +219,31 @@ class EmailAPI {
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
Future<bool> markAsImportant(AccountId accountId, EmailId emailId, ImportantAction importantAction) async {
|
||||
final setEmailMethod = SetEmailMethod(accountId)
|
||||
..addUpdates({
|
||||
emailId.id: KeyWordIdentifier.emailFlagged.generateImportantActionPath(importantAction)
|
||||
});
|
||||
|
||||
final requestBuilder = JmapRequestBuilder(_httpClient, ProcessingInvocation());
|
||||
|
||||
final setEmailInvocation = requestBuilder.invocation(setEmailMethod);
|
||||
|
||||
final response = await (requestBuilder
|
||||
..usings(setEmailMethod.requiredCapabilities))
|
||||
.build()
|
||||
.execute();
|
||||
|
||||
final setEmailResponse = response.parse<SetEmailResponse>(
|
||||
setEmailInvocation.methodCallId,
|
||||
SetEmailResponse.deserialize);
|
||||
|
||||
return Future.sync(() async {
|
||||
final emailUpdated = setEmailResponse!.updated![emailId.id];
|
||||
return emailUpdated == null;
|
||||
}).catchError((error) {
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -59,4 +59,9 @@ class EmailRepositoryImpl extends EmailRepository {
|
||||
Future<List<EmailId>> moveToMailbox(AccountId accountId, MoveRequest moveRequest) {
|
||||
return emailDataSource.moveToMailbox(accountId, moveRequest);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> markAsImportant(AccountId accountId, EmailId emailId, ImportantAction importantAction) {
|
||||
return emailDataSource.markAsImportant(accountId, emailId, importantAction);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user