mirror of
https://github.com/moparisthebest/mail
synced 2024-11-26 19:02:20 -05:00
Merge remote-tracking branch 'origin/delete_async'
This commit is contained in:
commit
b0b5c0ab4a
@ -167,6 +167,10 @@ define(function(require) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!email.unread) {
|
||||
return;
|
||||
}
|
||||
|
||||
email.unread = false;
|
||||
emailDao.imapMarkMessageRead({
|
||||
folder: getFolder().path,
|
||||
|
@ -51,10 +51,33 @@ define(function(require) {
|
||||
};
|
||||
|
||||
$scope.remove = function(email) {
|
||||
if (!email) {
|
||||
return;
|
||||
}
|
||||
|
||||
var index;
|
||||
removeLocalAndShowNext();
|
||||
removeRemote();
|
||||
|
||||
function removeLocalAndShowNext() {
|
||||
index = $scope.emails.indexOf(email);
|
||||
// show the next mail
|
||||
if ($scope.emails.length > 1) {
|
||||
// if we're about to delete the last entry of the array, show the previous (i.e. the one below in the list),
|
||||
// otherwise show the next one (i.e. the one above in the list)
|
||||
$scope.select(_.last($scope.emails) === email ? $scope.emails[index - 1] : $scope.emails[index + 1]);
|
||||
} else {
|
||||
// if we have only one email in the array, show nothing
|
||||
$scope.select();
|
||||
$scope.selected = undefined;
|
||||
}
|
||||
$scope.emails.splice(index, 1);
|
||||
}
|
||||
|
||||
function removeRemote() {
|
||||
var trashFolder = _.findWhere($scope.folders, {
|
||||
type: 'Trash'
|
||||
});
|
||||
|
||||
if ($scope.currentFolder === trashFolder) {
|
||||
emailDao.imapDeleteMessage({
|
||||
folder: $scope.currentFolder.path,
|
||||
@ -68,28 +91,15 @@ define(function(require) {
|
||||
uid: email.uid,
|
||||
destination: trashFolder.path
|
||||
}, moved);
|
||||
}
|
||||
|
||||
function moved(err) {
|
||||
var index;
|
||||
|
||||
if (err) {
|
||||
console.error(err);
|
||||
$scope.emails.splice(index, 0, email);
|
||||
$scope.$apply();
|
||||
return;
|
||||
}
|
||||
|
||||
index = $scope.emails.indexOf(email);
|
||||
// show the next mail
|
||||
if ($scope.emails.length > 1) {
|
||||
// if we're about to delete the last entry of the array, show the previous (i.e. the one below in the list),
|
||||
// otherwise show the next one (i.e. the one above in the list)
|
||||
$scope.select(_.last($scope.emails) === email ? $scope.emails[index - 1] : $scope.emails[index + 1]);
|
||||
} else {
|
||||
// if we have only one email in the array, show nothing
|
||||
$scope.select();
|
||||
$scope.selected = undefined;
|
||||
}
|
||||
$scope.emails.splice(index, 1);
|
||||
$scope.$apply();
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user