From d544b2cf3dd57bf71ee21f456f362ee685b2757e Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Wed, 13 Nov 2013 17:05:21 +0100 Subject: [PATCH] [WO-112] Mark replied to emails as answered --- src/js/controller/navigation.js | 4 ++++ src/js/controller/write.js | 28 ++++++++++++++++++++++------ src/js/dao/email-dao.js | 10 ++++++++++ src/tpl/mail-list.html | 2 +- test/new-unit/email-dao-test.js | 15 +++++++++++++++ 5 files changed, 52 insertions(+), 7 deletions(-) diff --git a/src/js/controller/navigation.js b/src/js/controller/navigation.js index 2b6d48c..fc5f21f 100644 --- a/src/js/controller/navigation.js +++ b/src/js/controller/navigation.js @@ -23,6 +23,10 @@ define(function(require) { // $scope.$root.onError = function(options) { + if (!options) { + return; + } + console.error(options); $scope.state.dialog = { open: true, diff --git a/src/js/controller/write.js b/src/js/controller/write.js index 9b6b4fc..bbfa10c 100644 --- a/src/js/controller/write.js +++ b/src/js/controller/write.js @@ -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) { diff --git a/src/js/dao/email-dao.js b/src/js/dao/email-dao.js index 87c807a..9d8dcee 100644 --- a/src/js/dao/email-dao.js +++ b/src/js/dao/email-dao.js @@ -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 // diff --git a/src/tpl/mail-list.html b/src/tpl/mail-list.html index 9546da7..aaae82c 100644 --- a/src/tpl/mail-list.html +++ b/src/tpl/mail-list.html @@ -6,7 +6,7 @@