Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/19/2016 07:55:22 PM (9 years ago)
Author:
imath
Message:

Make sure notifications are marked as read when loading new mentions from the activity directory.

When a user has new mentions, the mentions tab of the activity directory displays the count of the new mantions available. When clicking on this tab, we need to make sure the corresponding notification entries are marked as read by the Notifications component.

Fixes #6687

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-notifications.php

    r10417 r10457  
    500500 *
    501501 * @since 1.5.0
    502  *
     502 * @since 2.5.0 Add the $user_id parameter
     503 *
     504 * @param int $user_id The id of the user whose notifications are marked as read.
    503505 * @uses bp_notifications_mark_all_notifications_by_type()
    504506 */
    505 function bp_activity_remove_screen_notifications() {
     507function bp_activity_remove_screen_notifications( $user_id = 0 ) {
    506508    if ( ! bp_is_active( 'notifications' ) ) {
    507509        return;
    508510    }
    509511
    510     // Only mark read if you're looking at your own mentions.
    511     if ( ! bp_is_my_profile() ) {
     512    // Only mark read if the current user is looking at his own mentions.
     513    if ( empty( $user_id ) || (int) $user_id !== (int) bp_loggedin_user_id() ) {
    512514        return;
    513515    }
    514516
    515     bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->activity->id, 'new_at_mention' );
    516 }
    517 add_action( 'bp_activity_screen_mentions', 'bp_activity_remove_screen_notifications' );
     517    bp_notifications_mark_notifications_by_type( $user_id, buddypress()->activity->id, 'new_at_mention' );
     518}
     519add_action( 'bp_activity_clear_new_mentions', 'bp_activity_remove_screen_notifications', 10, 1 );
    518520
    519521/**
Note: See TracChangeset for help on using the changeset viewer.