[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) {
if (!options) {
return;
}
console.error(options);
$scope.state.dialog = {
open: true,

View File

@ -24,12 +24,14 @@ define(function(require) {
open: false,
write: function(replyTo) {
this.open = true;
$scope.replyTo = replyTo;
resetFields();
if (replyTo) {
fillFields(replyTo);
$scope.updatePreview();
}
// fill fields depending on replyTo
fillFields(replyTo);
$scope.updatePreview();
$scope.verifyTo();
},
close: function() {
@ -86,7 +88,7 @@ define(function(require) {
// check if to address is contained in known public keys
emailDao._keychain.getReceiverPublicKey($scope.to, function(err, key) {
if (err) {
console.error(err);
$scope.onError(err);
return;
}
@ -174,15 +176,29 @@ define(function(require) {
email.id = util.UUID();
emailDao._devicestorage.storeList([email], 'email_OUTBOX', function(err) {
if (err) {
console.error(err);
$scope.onError(err);
return;
}
$scope.state.writer.close();
$scope.$apply();
$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) {

View File

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

View File

@ -6,7 +6,7 @@
<div class="list-wrapper" ng-iscroll="emails">
<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>
<div class="head">
<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();
});
});
});
});
});