Skip to content

Commit 76c7d73

Browse files
committed
Only redirect after deleting a post if we're not already on map/timeline
Only redirect if we're not on map or timeline. Otherwise just reload to ensure post it dropped from view. Refs ushahidi/platform#1482
1 parent debf4aa commit 76c7d73

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

app/main/posts/common/post-actions.directive.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ PostActionsDirective.$inject = [
44
'PostEndpoint',
55
'Notify',
66
'$location',
7+
'$route',
78
'PostActionsService'
89
];
910
function PostActionsDirective(
1011
PostEndpoint,
1112
Notify,
1213
$location,
14+
$route,
1315
PostActionsService
1416
) {
1517
return {
@@ -34,7 +36,15 @@ function PostActionsDirective(
3436

3537
function deletePost() {
3638
PostActionsService.delete($scope.post).then(function () {
37-
$location.path('/views/list');
39+
// If we're not already on some top level view
40+
if ($location.path().indexOf('views') === -1 &&
41+
$location.path().indexOf('collections') === -1 &&
42+
$location.path().indexOf('savedsearches') === -1) {
43+
// Redirect to list
44+
$location.path('/views/list');
45+
} else {
46+
$route.reload();
47+
}
3848
});
3949
}
4050

0 commit comments

Comments
 (0)