mirror of
https://github.com/moparisthebest/mail
synced 2024-11-23 09:22:23 -05:00
Merge remote-tracking branch 'origin/delete_async'
This commit is contained in:
commit
b0b5c0ab4a
@ -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,
|
||||||
|
@ -51,10 +51,33 @@ define(function(require) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.remove = function(email) {
|
$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, {
|
var trashFolder = _.findWhere($scope.folders, {
|
||||||
type: 'Trash'
|
type: 'Trash'
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($scope.currentFolder === trashFolder) {
|
if ($scope.currentFolder === trashFolder) {
|
||||||
emailDao.imapDeleteMessage({
|
emailDao.imapDeleteMessage({
|
||||||
folder: $scope.currentFolder.path,
|
folder: $scope.currentFolder.path,
|
||||||
@ -68,28 +91,15 @@ define(function(require) {
|
|||||||
uid: email.uid,
|
uid: email.uid,
|
||||||
destination: trashFolder.path
|
destination: trashFolder.path
|
||||||
}, moved);
|
}, moved);
|
||||||
|
}
|
||||||
|
|
||||||
function moved(err) {
|
function moved(err) {
|
||||||
var index;
|
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
$scope.emails.splice(index, 0, email);
|
||||||
|
$scope.$apply();
|
||||||
return;
|
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