1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-23 09:22:23 -05:00

delete mail displays next mail

This commit is contained in:
Felix Hammerl 2013-10-17 10:36:50 +02:00
parent 1eac9ef75d
commit 8c6c6a8ab2
2 changed files with 16 additions and 2 deletions

View File

@ -18,7 +18,7 @@ define(function(require) {
// scope functions
//
$scope.select = function(email) {
$scope.$parent.select = $scope.select = function(email) {
if (!email) {
return;
}

View File

@ -52,11 +52,25 @@ define(function(require) {
}, moved);
function moved(err) {
var index;
if (err) {
console.error(err);
return;
}
$scope.emails.splice($scope.emails.indexOf(email), 1);
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();
}
};