Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/bp-templates/bp-nouveau/js/buddypress-activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,43 @@ window.bp = window.bp || {};
}
}

// Deleting the activity from inside the "view more comments"
// modal removes only the modal's copy of the entry below -
// the feed's copy stays stale and the modal is left open as
// an empty shell. Drop the feed copy, close the modal through
// its real close button, and anchor the feed on the deleted
// post's neighbor so the user lands at the right position.
// The close empties the modal list, so the slideUp below runs
// on a detached node for this path - intentional no-op.
if ( ! ajaxData.is_comment && li_parent.closest( '#activity-modal' ).length ) {
var $feedCopy = $( '#activity-stream li.activity-item[data-bp-activity-id="' + ajaxData.id + '"]' );
var $feedAnchor = $feedCopy.prevAll( 'li.activity-item:not(.activity-popup)' ).first();
if ( ! $feedAnchor.length ) {
$feedAnchor = $feedCopy.nextAll( 'li.activity-item:not(.activity-popup)' ).first();
}

// A pin toggled from inside the modal is moot once the post
// is deleted - left set, the close-button's sync handler
// reloads the whole feed over the anchor scroll below.
bp.Nouveau.Activity.activityPinHasUpdates = false;

$feedCopy.remove();

var $modalCloseButton = $( '#activity-modal .bb-modal-activity-header .bb-close-action-popup' );
if ( $modalCloseButton.length ) {
$modalCloseButton.trigger( 'click' );
} else {
// A theme override may rename the close control - never
// leave the emptied modal open.
$( '#activity-modal' ).closest( '.bb-activity-model-wrapper' ).hide();
}

if ( $feedAnchor.length ) {
var adminBar = $( '#wpadminbar' ).length !== 0 ? $( '#wpadminbar' ).innerHeight() : 0;
$( 'html, body' ).animate( { scrollTop: parseInt( $feedAnchor.offset().top ) - ( 80 + adminBar ) }, 300 );
}
}

// Remove the entry.
li_parent.slideUp(
300,
Expand Down
2 changes: 1 addition & 1 deletion src/bp-templates/bp-nouveau/js/buddypress-activity.min.js

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions src/bp-templates/bp-nouveau/js/buddypress-media.js
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,29 @@ window.bp = window.bp || {};
$( 'body #buddypress .activity-list li#activity-' + activityId ).remove();
$( 'body .bb-activity-media-elem.media-activity.' + id ).remove();
$( 'body .activity-comments li#acomment-' + activityId ).remove();

// The selectors above also clear the "view more comments"
// modal's copy of the activity, which leaves the modal open
// as an empty shell. When the modal's list has been emptied,
// close it through its real close button so the close
// handler runs; hide the wrapper directly if a theme
// override renamed the button.
var $activityModal = $( '#activity-modal:visible' );
if ( $activityModal.length && 0 === $activityModal.find( '.bb-modal-activity-body .activity-list li' ).length ) {
var $modalCloseButton = $activityModal.find( '.bb-modal-activity-header .bb-close-action-popup' );
if ( $modalCloseButton.length ) {
// A pin toggled from inside the modal is moot once the
// post is deleted - left set, the close-button's sync
// handler reloads the whole feed (same reset as the
// direct-delete path in buddypress-activity.js).
if ( 'undefined' !== typeof bp.Nouveau.Activity ) {
bp.Nouveau.Activity.activityPinHasUpdates = false;
}
$modalCloseButton.trigger( 'click' );
} else {
$activityModal.closest( '.bb-activity-model-wrapper' ).hide();
}
}
} else {
$( 'body #buddypress .activity-list li#activity-' + activityId ).replaceWith( response.data.activity_content );
}
Expand Down
2 changes: 1 addition & 1 deletion src/bp-templates/bp-nouveau/js/buddypress-media.min.js

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions src/bp-templates/bp-nouveau/readylaunch/js/buddypress-activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -3080,6 +3080,38 @@ window.bp = window.bp || {};
}
}

// Deleting the activity from inside the "view more comments"
// modal removes only the modal's copy of the entry below -
// the feed's copy stays stale and the modal is left open as
// an empty shell. Drop the feed copy, close the modal through
// its real close button, and anchor the feed on the deleted
// post's neighbor so the user lands at the right position.
// The close empties the modal list, so the slideUp below runs
// on a detached node for this path - intentional no-op.
if ( ! ajaxData.is_comment && li_parent.closest( '#bb-rl-activity-modal' ).length ) {
var $feedCopy = $( '#bb-rl-activity-stream li.activity-item[data-bp-activity-id="' + ajaxData.id + '"]' );
var $feedAnchor = $feedCopy.prevAll( 'li.activity-item:not(.bb-rl-activity-popup)' ).first();
if ( ! $feedAnchor.length ) {
$feedAnchor = $feedCopy.nextAll( 'li.activity-item:not(.bb-rl-activity-popup)' ).first();
}

$feedCopy.remove();

var $modalCloseButton = $( '#bb-rl-activity-modal .bb-rl-modal-activity-header .bb-rl-close-action-popup' );
if ( $modalCloseButton.length ) {
$modalCloseButton.trigger( 'click' );
} else {
// A theme override may rename the close control - never
// leave the emptied modal open.
$( '#bb-rl-activity-modal' ).closest( '.bb-rl-activity-model-wrapper' ).hide();
}

if ( $feedAnchor.length ) {
var adminBar = $( '#wpadminbar' ).length !== 0 ? $( '#wpadminbar' ).innerHeight() : 0;
$( 'html, body' ).animate( { scrollTop: parseInt( $feedAnchor.offset().top ) - ( 80 + adminBar ) }, 300 );
}
}

// Remove the entry.
li_parent.slideUp(
300,
Expand Down

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions src/bp-templates/bp-nouveau/readylaunch/js/buddypress-media.js
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,22 @@ window.bp = window.bp || {};
$( 'body #buddypress .bb-rl-activity-list li#bb-rl-activity-' + activityId ).remove();
$( 'body .bb-rl-activity-media-elem.bb-rl-media-activity.' + id ).remove();
$( 'body .bb-rl-activity-comments li#bb-rl-acomment-' + activityId ).remove();

// The selectors above also clear the "view more comments"
// modal's copy of the activity, which leaves the modal open
// as an empty shell. When the modal's list has been emptied,
// close it through its real close button so the close
// handler runs; hide the wrapper directly if a theme
// override renamed the button.
var $activityModal = $( '#bb-rl-activity-modal:visible' );
if ( $activityModal.length && 0 === $activityModal.find( '.bb-rl-modal-activity-body .bb-rl-activity-list li' ).length ) {
var $modalCloseButton = $activityModal.find( '.bb-rl-modal-activity-header .bb-rl-close-action-popup' );
if ( $modalCloseButton.length ) {
$modalCloseButton.trigger( 'click' );
} else {
$activityModal.closest( '.bb-rl-activity-model-wrapper' ).hide();
}
}
} else {
$( 'body #buddypress .bb-rl-activity-list li#bb-rl-activity-' + activityId ).replaceWith( response.data.activity_content );
}
Expand Down

Large diffs are not rendered by default.

Loading