Skip to:

Opened 5 years ago

Closed 5 years ago

#8035 closed defect (bug) (fixed)

Nouveau: AJAX filter in Friends Requests returns incorrect and incorrectly-formatted results

Reported by: oxibug's profile oxibug Owned by: boonebgorges's profile boonebgorges
Milestone: 5.0.0 Priority: normal
Severity: major Version: 3.0.0
Component: Friends Keywords: dev-feedback has-screenshots has-patch


Hi There!

WordPress 5.0.2 Multisite - Configured properly in wp-config
BuddyPress v4.1.0
bpDefaultData plugin to test - User Antawn
Theme: Twenty Seventeen

NOTE: This issue appears also in single sites

I noticed that my style corrupted in the Friends > Requests after using dropdown filter, and it doesn't happen in the Friends > Friendships So I took a screenshots for normal state and after using AJAX filter.

Issue: The main filter doesn't replace the main ul but it creates another ul inside it instead.


Attachments (3)

buddypress-issue-friend-request.jpg (310.9 KB) - added by oxibug 5 years ago.
Friends Request AJAX filter issue
8035.diff (6.2 KB) - added by boonebgorges 5 years ago.
8035.2.diff (6.3 KB) - added by imath 5 years ago.
Uses --no-prefix to ease patch testing ;)

Download all attachments as: .zip

Change History (11)

5 years ago

Friends Request AJAX filter issue

#1 @oxibug
5 years ago

  • Keywords dev-feedback added; reporter-feedback removed

#2 @boonebgorges
5 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone changed from Awaiting Review to 5.0.0
  • Priority changed from omg pizza to normal
  • Summary changed from Fatal mistake while using AJAX filter in Friends Requests to Nouveau: AJAX filter in Friends Requests returns incorrect and incorrectly-formatted results
  • Version changed from 4.1.0 to 3.0.0

Hi @oxibug - Thanks for the ticket!

I see two issues:

  1. The incorrect results are being returned from the AJAX request. It's querying for all members instead of just friend requests.
  1. The structure of the post-AJAX markup is not correct (as you note in your screenshots)

It looks to me like this part of the interface may not have been fully reviewed when Nouveau was built - there's some copypasta from Legacy that doesn't totally work :) And, since Legacy doesn't support the 'filter' on /friends/requests, it's kinda broken in Nouveau too.

The attached patch fixes it, though I'd like a second look (from @imath perhaps?) to see if I'm following Nouveau conventions closely enough. The critical parts are:

  1. To fix the markup issues, I had to create a new requests-loop template.
  2. That requests-loop template now uses bp_ajax_querystring(), which lets the AJAX filters work.
  3. To make the AJAX request fetch membership requests rather than all members, I had to do some customization of the template value sent in the AJAX request. I used group membership requests as a benchmark for this, but the case is slightly different here, since there's built-in logic in Groups to look at bp_current_action(), but not in Members. See bp_nouveau_current_object().

#3 @imath
5 years ago

Hi @boonebgorges !!

I'll have a look at the patch asap. But I think you forgot to attach it to the ticket :)

5 years ago

#5 @imath
5 years ago

😇 @boonebgorges I just gave it a look, it looks really nice. I haven't tested it yet. It's quite late for me tonight, but i will test it tomorrow for sure.

After this first look, I see a little improvement about template files inline docs. In the file you added, i think it would be better if it looked like :

 * BuddyPress - Members Friends Requests Loop
 * @since 5.0.0
 * @version 5.0.0

And in the template file you edited, updating the version the template changed would be great :)

 * BuddyPress - Members Friends Requests
 * @since 3.0.0
 * @version 5.0.0

I'll confirm tomorrow for the Ajax part. 😴

5 years ago

Uses --no-prefix to ease patch testing ;)

#6 @imath
5 years ago

@boonebgorges it works great ! Thanks a lot for your work on this. As I needed to set files to patch, I've just uploaded .2.diff using git diff --no-prefix. I also added the inline comments I was talking about in my previous comment.

#7 @boonebgorges
5 years ago

Thanks for having a look, @imath !

#8 @boonebgorges
5 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 12322:

Nouveau: Fixes for the Friends Request page.

The Friends Request page was introduced in Nouveau with the same dropdown
filter as on other member directories, but the functionality was never
fully implemented. In this changeset, we make the following changes:

  • Ensure that the AJAX request distinguishes between friend request queries and other membership queries, so that the members returned are limited to friend requests.
  • Break the friend request loop logic into its own template, so that the outer template information (title, pagination, etc) doesn't appear twice after an AJAX filter.
  • Modify the logic in the friend-request template so that it uses bp_ajax_querystring(), which lets the filters affect the returned results.

Props imath.
Fixes #8035.

Note: See TracTickets for help on using tickets.