mirror of
https://github.com/moparisthebest/mail
synced 2024-11-27 03:12:23 -05:00
delete mail displays next mail
This commit is contained in:
parent
1eac9ef75d
commit
8c6c6a8ab2
@ -18,7 +18,7 @@ define(function(require) {
|
|||||||
// scope functions
|
// scope functions
|
||||||
//
|
//
|
||||||
|
|
||||||
$scope.select = function(email) {
|
$scope.$parent.select = $scope.select = function(email) {
|
||||||
if (!email) {
|
if (!email) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -52,11 +52,25 @@ define(function(require) {
|
|||||||
}, moved);
|
}, moved);
|
||||||
|
|
||||||
function moved(err) {
|
function moved(err) {
|
||||||
|
var index;
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
return;
|
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();
|
$scope.$apply();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user