From d4398ebbb88687015911c5b977594204f64d0c72 Mon Sep 17 00:00:00 2001 From: Felix Hammerl Date: Thu, 24 Oct 2013 15:18:16 +0200 Subject: [PATCH 1/2] [WO-29] omit unnecessary flag update --- src/js/controller/mail-list.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/js/controller/mail-list.js b/src/js/controller/mail-list.js index e17b128..9d3f419 100644 --- a/src/js/controller/mail-list.js +++ b/src/js/controller/mail-list.js @@ -167,6 +167,10 @@ define(function(require) { return; } + if (!email.unread) { + return; + } + email.unread = false; emailDao.imapMarkMessageRead({ folder: getFolder().path, From 9d1b2e33ef3a6488767f74edbb25809cd795d782 Mon Sep 17 00:00:00 2001 From: Felix Hammerl Date: Thu, 24 Oct 2013 15:18:51 +0200 Subject: [PATCH 2/2] [WO-29] delete messages asynchronously --- src/js/controller/navigation.js | 56 +++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/src/js/controller/navigation.js b/src/js/controller/navigation.js index 0323a21..16e15ce 100644 --- a/src/js/controller/navigation.js +++ b/src/js/controller/navigation.js @@ -50,32 +50,15 @@ define(function(require) { }; $scope.remove = function(email) { - var trashFolder = _.findWhere($scope.folders, { - type: 'Trash' - }); - - if ($scope.currentFolder === trashFolder) { - emailDao.imapDeleteMessage({ - folder: $scope.currentFolder.path, - uid: email.uid - }, moved); + if (!email) { return; } - emailDao.imapMoveMessage({ - folder: $scope.currentFolder.path, - uid: email.uid, - destination: trashFolder.path - }, moved); - - function moved(err) { - var index; - - if (err) { - console.error(err); - return; - } + var index; + removeLocalAndShowNext(); + removeRemote(); + function removeLocalAndShowNext() { index = $scope.emails.indexOf(email); // show the next mail if ($scope.emails.length > 1) { @@ -88,7 +71,34 @@ define(function(require) { $scope.selected = undefined; } $scope.emails.splice(index, 1); - $scope.$apply(); + } + + function removeRemote() { + var trashFolder = _.findWhere($scope.folders, { + type: 'Trash' + }); + if ($scope.currentFolder === trashFolder) { + emailDao.imapDeleteMessage({ + folder: $scope.currentFolder.path, + uid: email.uid + }, moved); + return; + } + + emailDao.imapMoveMessage({ + folder: $scope.currentFolder.path, + uid: email.uid, + destination: trashFolder.path + }, moved); + } + + function moved(err) { + if (err) { + console.error(err); + $scope.emails.splice(index, 0, email); + $scope.$apply(); + return; + } } };