Skip to:
Content
Pages
Categories
Search
Top
Bottom

BP user @mention


  • Praveen Kumar
    Participant

    @praveenkumar98

    Hi Team,

    I am encountering an issue with user mentions in the BuddyPress activity stream. Currently, an AJAX request is sent for each letter typed by the user, which results in a long response time. I am looking for a way to control these AJAX requests so that a request is only sent after the user has finished typing. Can you provide guidance or suggest a method to implement this functionality?

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)

  • Varun Dubey
    Participant

    @vapvarun

    Implement a debounce function to delay AJAX requests until the user has stopped typing for a specified duration. This will reduce the number of requests and improve responsiveness. The debounced function can be added to the input event in the “What’s new” section of the BuddyPress activity stream.
    https://dev.to/zahoorcodes/benefits-of-delaying-ajax-calls-2f35


    Praveen Kumar
    Participant

    @praveenkumar98

    Hi Varun,

    Thanks for your response.

    I was wondering if it’s possible to add a debounce function without modifying the core BuddyPress files. I’ve attempted to create a custom file where I wrap the original remoteFilter function with a debounce function and then enqueue this script in the theme’s functions.php file.

    Here’s the approach I’ve taken:

    mentionsDefaults.callbacks.remoteFilter = debounce(function(query, render_view) {
    originalRemoteFilter.call(this, query, render_view);
    }, debounceTime);

    Could you please advise if this is the correct approach or if there is a better way to achieve this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar