Changeset 13383
- Timestamp:
- 12/14/2022 09:42:06 PM (2 years ago)
- Location:
- trunk/src/bp-messages
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/actions/view.php
r13096 r13383 54 54 */ 55 55 if ( bp_is_my_profile() ) { 56 // This is marking the messages as read inside the BP Messages component's recipient table. 56 57 messages_mark_thread_read( $thread_id ); 57 58 } -
trunk/src/bp-messages/bp-messages-notifications.php
r13269 r13383 262 262 * @param int $user_id ID of the user who read the thread. 263 263 * @param int $num_rows The number of affected rows by the "mark read" update query. 264 * @return bool True on success. False otherwise. 264 265 */ 265 266 function bp_messages_mark_notification_on_mark_thread( $thread_id, $user_id = 0, $num_rows = 0 ) { 267 $unread_messages = array(); 268 266 269 if ( ! $num_rows ) { 267 return; 270 /** 271 * The thread might have been marked read, but a notification about the thread might also have been 272 * marked back as unread from the BP Notifications screen. We then need to check a notification exists 273 * about `new_message` action before checking found message ids are part of the thread. 274 * 275 * @see https://buddypress.trac.wordpress.org/ticket/8778 276 */ 277 $notifications = bp_notifications_get_all_notifications_for_user( $user_id ); 278 if ( $notifications ) { 279 $unread_messages = wp_filter_object_list( 280 $notifications, 281 array( 282 'component_action' => 'new_message', 283 'is_new' => 1, 284 ), 285 'and', 286 'item_id' 287 ); 288 289 $num_rows = count( $unread_messages ); 290 if ( $num_rows ) { 291 $unread_messages = array_map( 'intval', $unread_messages ); 292 } else { 293 return false; 294 } 295 } 268 296 } 269 297 … … 271 299 $message_ids = wp_list_pluck( $thread_messages, 'id' ); 272 300 273 bp_notifications_mark_notifications_by_item_ids( $user_id, $message_ids, 'messages', 'new_message', false ); 301 if ( $unread_messages && ! array_intersect( $message_ids, $unread_messages ) ) { 302 return false; 303 } 304 305 return bp_notifications_mark_notifications_by_item_ids( $user_id, $message_ids, 'messages', 'new_message', false ); 274 306 } 275 307 add_action( 'messages_thread_mark_as_read', 'bp_messages_mark_notification_on_mark_thread', 10, 3 );
Note: See TracChangeset
for help on using the changeset viewer.