From 6952dd47d894eafaa23b9577665843ca0aadf768 Mon Sep 17 00:00:00 2001
From: Christoph Herbst <chris.p.herbst@gmail.com>
Date: Fri, 14 Feb 2020 15:26:03 +0100
Subject: [PATCH] fix reply notifications

---
 includes/extend/buddypress/notifications.php | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/includes/extend/buddypress/notifications.php b/includes/extend/buddypress/notifications.php
index 5f6b6b0..8592ddf 100644
--- a/includes/extend/buddypress/notifications.php
+++ b/includes/extend/buddypress/notifications.php
@@ -62,7 +62,7 @@ function bbp_filter_notifications_get_registered_components( $component_names =
 function bbp_format_buddypress_notifications( $content, $item_id, $secondary_item_id, $action_item_count, $format, $component_action_name, $component_name, $id ) {
 
 	// Bail if not the notification action we are looking for
-	if ( 'bbp_new_reply' !== $component_action_name ) {
+	if ( strpos( $component_action_name, 'bbp_new_reply' ) !== 0 ) {
 		return $content;
 	}
 
@@ -86,7 +86,7 @@ function bbp_format_buddypress_notifications( $content, $item_id, $secondary_ite
 	// Multiple
 	if ( $action_item_count > 1 ) {
 		$filter = 'bbp_multiple_new_subscription_notification';
-		$text   = sprintf( esc_html__( 'You have %d new replies', 'bbpress' ), $action_item_count );
+		$text   = sprintf( esc_html__( 'You have %d new replies to %s', 'bbpress' ), $action_item_count, $topic_title );
 
 	// Single
 	} else {
@@ -148,7 +148,7 @@ function bbp_buddypress_add_notification( $reply_id = 0, $topic_id = 0, $forum_i
 		'user_id'          => $topic_author_id,
 		'item_id'          => $reply_id,
 		'component_name'   => bbp_get_component_name(),
-		'component_action' => 'bbp_new_reply',
+		'component_action' => "bbp_new_reply_$topic_id",
 		'date_notified'    => get_post( $reply_id )->post_date,
 	);
 
@@ -204,7 +204,7 @@ function bbp_buddypress_mark_notifications( $action = '' ) {
 	if ( ! bbp_has_errors() ) {
 
 		// Attempt to clear notifications for the current user from this topic
-		$success = bp_notifications_mark_notifications_by_item_id( $user_id, $topic_id, bbp_get_component_name(), 'bbp_new_reply' );
+		$success = bp_notifications_mark_notifications_by_type( $user_id, bbp_get_component_name(), "bbp_new_reply_$topic_id" );
 
 		// Do additional subscriptions actions
 		do_action( 'bbp_notifications_handler', $success, $user_id, $topic_id, $action );
-- 
2.20.1

