@@ -181,7 +181,7 @@ function PostViewDataController(
181
181
) ;
182
182
183
183
$scope . $on ( 'event:edit:leave:form:complete' , function ( ) {
184
- // Bercause there is no state management
184
+ // Because there is no state management
185
185
// We copy the next Post to be the current Post
186
186
// if the previous Post exited correctly
187
187
// Ideally Post Card would become a service more akin
@@ -255,9 +255,11 @@ function PostViewDataController(
255
255
function removePostFromList ( postObj ) {
256
256
$scope . posts . forEach ( ( post , index ) => {
257
257
// args.post is the post being updated/saved and sent from the broadcast
258
+ // since a single post is being deleted here, reduce count of totalitems by 1.
258
259
if ( post . id === postObj . id ) {
259
260
let nextInLine = $scope . posts [ index + 1 ] ;
260
261
$scope . posts . splice ( index , 1 ) ;
262
+ $scope . totalItems = $scope . totalItems - 1 ;
261
263
if ( $scope . posts . length ) {
262
264
groupPosts ( $scope . posts ) ;
263
265
if ( $scope . selectedPost . post ) {
@@ -329,7 +331,6 @@ function PostViewDataController(
329
331
PostEndpoint . query ( postQuery ) . $promise . then ( function ( postsResponse ) {
330
332
//Clear posts
331
333
clearPosts ? resetPosts ( ) : null ;
332
-
333
334
// If we're loading posts for the first time and we have a selected post (post detail view)
334
335
// check to see that the selected post isn't in the list
335
336
// and then deselect it and select the first item
@@ -360,6 +361,7 @@ function PostViewDataController(
360
361
} ) ;
361
362
}
362
363
364
+ // this function is called when multiple data items are deleted
363
365
function deletePosts ( ) {
364
366
Notify . confirmDelete ( 'notify.post.bulk_destroy_confirm' , { count : $scope . selectedPosts . length } ) . then ( function ( ) {
365
367
// ask server to delete selected posts
0 commit comments