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;
}
if (!email.unread) {
return;
}
email.unread = false;
emailDao.imapMarkMessageRead({
folder: getFolder().path,

View File

@ -51,32 +51,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) {
@ -89,7 +72,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;
}
}
};