1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-23 01:12:19 -05:00

Merge remote-tracking branch 'origin/delete_async'

This commit is contained in:
Tankred Hase 2013-10-24 19:40:32 +02:00
commit b0b5c0ab4a
2 changed files with 37 additions and 23 deletions

View File

@ -167,6 +167,10 @@ define(function(require) {
return; return;
} }
if (!email.unread) {
return;
}
email.unread = false; email.unread = false;
emailDao.imapMarkMessageRead({ emailDao.imapMarkMessageRead({
folder: getFolder().path, folder: getFolder().path,

View File

@ -51,32 +51,15 @@ define(function(require) {
}; };
$scope.remove = function(email) { $scope.remove = function(email) {
var trashFolder = _.findWhere($scope.folders, { if (!email) {
type: 'Trash'
});
if ($scope.currentFolder === trashFolder) {
emailDao.imapDeleteMessage({
folder: $scope.currentFolder.path,
uid: email.uid
}, moved);
return; return;
} }
emailDao.imapMoveMessage({ var index;
folder: $scope.currentFolder.path, removeLocalAndShowNext();
uid: email.uid, removeRemote();
destination: trashFolder.path
}, moved);
function moved(err) {
var index;
if (err) {
console.error(err);
return;
}
function removeLocalAndShowNext() {
index = $scope.emails.indexOf(email); index = $scope.emails.indexOf(email);
// show the next mail // show the next mail
if ($scope.emails.length > 1) { if ($scope.emails.length > 1) {
@ -89,7 +72,34 @@ define(function(require) {
$scope.selected = undefined; $scope.selected = undefined;
} }
$scope.emails.splice(index, 1); $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;
}
} }
}; };