1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-29 12:22:22 -05:00

[WO-112] Mark replied to emails as answered

This commit is contained in:
Tankred Hase 2013-11-13 17:05:21 +01:00
parent d779ef679d
commit d544b2cf3d
5 changed files with 52 additions and 7 deletions

View File

@ -23,6 +23,10 @@ define(function(require) {
// //
$scope.$root.onError = function(options) { $scope.$root.onError = function(options) {
if (!options) {
return;
}
console.error(options); console.error(options);
$scope.state.dialog = { $scope.state.dialog = {
open: true, open: true,

View File

@ -24,12 +24,14 @@ define(function(require) {
open: false, open: false,
write: function(replyTo) { write: function(replyTo) {
this.open = true; this.open = true;
$scope.replyTo = replyTo;
resetFields(); resetFields();
if (replyTo) {
// fill fields depending on replyTo
fillFields(replyTo); fillFields(replyTo);
$scope.updatePreview(); $scope.updatePreview();
}
$scope.verifyTo(); $scope.verifyTo();
}, },
close: function() { close: function() {
@ -86,7 +88,7 @@ define(function(require) {
// check if to address is contained in known public keys // check if to address is contained in known public keys
emailDao._keychain.getReceiverPublicKey($scope.to, function(err, key) { emailDao._keychain.getReceiverPublicKey($scope.to, function(err, key) {
if (err) { if (err) {
console.error(err); $scope.onError(err);
return; return;
} }
@ -174,15 +176,29 @@ define(function(require) {
email.id = util.UUID(); email.id = util.UUID();
emailDao._devicestorage.storeList([email], 'email_OUTBOX', function(err) { emailDao._devicestorage.storeList([email], 'email_OUTBOX', function(err) {
if (err) { if (err) {
console.error(err); $scope.onError(err);
return; return;
} }
$scope.state.writer.close(); $scope.state.writer.close();
$scope.$apply(); $scope.$apply();
$scope.emptyOutbox(); $scope.emptyOutbox();
markAnwsered();
}); });
}; };
function markAnwsered() {
// mark replyTo as answered
if (!$scope.replyTo) {
return;
}
emailDao.imapMarkAnswered({
uid: $scope.replyTo.uid,
folder: $scope.state.nav.currentFolder.path
}, $scope.onError);
}
}; };
function parseBody(body) { function parseBody(body) {

View File

@ -516,6 +516,16 @@ define(function(require) {
}, callback); }, callback);
}; };
EmailDAO.prototype.imapMarkAnswered = function(options, callback) {
var self = this;
self._imapClient.updateFlags({
path: options.folder,
uid: options.uid,
answered: true
}, callback);
};
// //
// SMTP Apis // SMTP Apis
// //

View File

@ -6,7 +6,7 @@
<div class="list-wrapper" ng-iscroll="emails"> <div class="list-wrapper" ng-iscroll="emails">
<ul class="mail-list"> <ul class="mail-list">
<li ng-class="{'mail-list-active': email === state.mailList.selected, 'mail-list-attachment': email.attachments !== undefined && email.attachments.length > 0, 'mail-list-unread': email.unread, 'mail-list-replied': email.answered}" ng-click="select(email)" ng-repeat="email in emails"> <li ng-class="{'mail-list-active': email === state.mailList.selected, 'mail-list-attachment': email.attachments !== undefined && email.attachments.length > 0, 'mail-list-unread': email.unread && !email.answered, 'mail-list-replied': email.answered}" ng-click="select(email)" ng-repeat="email in emails">
<h3>{{email.from[0].name || email.from[0].address}}</h3> <h3>{{email.from[0].name || email.from[0].address}}</h3>
<div class="head"> <div class="head">
<p class="subject">{{email.subject || 'No subject'}}</p> <p class="subject">{{email.subject || 'No subject'}}</p>

View File

@ -750,6 +750,21 @@ define(function(require) {
}); });
}); });
describe('IMAP: mark message as answered', function() {
it('should work', function(done) {
imapClientStub.updateFlags.yields();
emailDao.imapMarkAnswered({
folder: 'asdf',
uid: 1
}, function(err) {
expect(imapClientStub.updateFlags.calledOnce).to.be.true;
expect(err).to.not.exist;
done();
});
});
});
}); });
}); });