Skip to content

Commit

Permalink
Only redirect after deleting a post if we're not already on map/timeline
Browse files Browse the repository at this point in the history
Only redirect if we're not on map or timeline. Otherwise just reload
to ensure post it dropped from view.

Refs ushahidi/platform#1482
  • Loading branch information
rjmackay committed Nov 8, 2016
1 parent debf4aa commit 76c7d73
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/main/posts/common/post-actions.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ PostActionsDirective.$inject = [
'PostEndpoint',
'Notify',
'$location',
'$route',
'PostActionsService'
];
function PostActionsDirective(
PostEndpoint,
Notify,
$location,
$route,
PostActionsService
) {
return {
Expand All @@ -34,7 +36,15 @@ function PostActionsDirective(

function deletePost() {
PostActionsService.delete($scope.post).then(function () {
$location.path('/views/list');
// If we're not already on some top level view
if ($location.path().indexOf('views') === -1 &&
$location.path().indexOf('collections') === -1 &&
$location.path().indexOf('savedsearches') === -1) {
// Redirect to list
$location.path('/views/list');
} else {
$route.reload();
}
});
}

Expand Down

0 comments on commit 76c7d73

Please sign in to comment.