get_new_messages loads all messages each ajax call

Created on 19 March 2024, 9 months ago
Updated 23 March 2024, 9 months ago

Problem/Motivation

Loading a thread /private-messages/1 calls get_new_messages, but each time it loads all messages in the thread. This only happens on the 3.0 branch.

Steps to reproduce

  • Send a message to a user
  • Open the thread at /private-messages/1
  • Wait a minute or so until the get_new_messages is called.
  • See duplicated messages appear in thread
  • Wait another minute until the get_new_messages is called again
  • See another duplicated message
  • ... this continues forever

Proposed resolution

Fix get_new_messages ajax callback to load only new messages.

Remaining tasks

Fix get_new_messages ajax callback to load only new messages.

User interface changes

None

API changes

TBD

Data model changes

TBD

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada sagesolutions

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @sagesolutions
  • Pipeline finished with Canceled
    9 months ago
    #126778
  • Pipeline finished with Failed
    9 months ago
    Total: 161s
    #126779
  • Status changed to Needs review 9 months ago
  • πŸ‡¨πŸ‡¦Canada sagesolutions

    I've created a MR for review. It's a bit hard to test since https://www.drupal.org/project/private_message/issues/3424499 πŸ› Stuck on undefined URL Needs review is not merged yet.

    I found the easiest way to test is to test with two browsers A and B and disable Javascript on B. Login to browser A with user 1 go to your private message chat with user 2. Then, send a message from user 2 on browser B to user 1. Back on browser A you should see the message appear without refreshing.

    Also, all messages now no longer load every minute!

    Please review!

  • πŸ‡¦πŸ‡ΊAustralia Stephen Ollman Canberra

    I'm sort of getting the opposite of this since moving to V3. Now I'm not seeing any new messages via an ajax callback. I need to manually refresh the page to see the new message.

  • πŸ‡¨πŸ‡¦Canada sagesolutions

    Hi Stephen,

    If you disable javascript, you will always need to manually refresh to see new messages appear. Ithink an easier way to test is to include the patch from https://www.drupal.org/project/private_message/issues/3424499 πŸ› Stuck on undefined URL Needs review and then test with javascript enabled.

  • Status changed to Needs work 9 months ago
  • πŸ‡¨πŸ‡¦Canada sagesolutions

    After further testing, this is close to working but there is still an issue. When I send a message to someone, I see it appear in the chat above. However, once the get_new_messages is called, my message that I just sent appears again. It only appears an extra time once, but still not ideal.

  • Status changed to Needs review 9 months ago
  • πŸ‡¨πŸ‡¦Canada sagesolutions

    Fixed the issue of reloading the message I just sent.

    Ready for review!

  • Pipeline finished with Failed
    9 months ago
    Total: 166s
    #131894
  • πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles

    Tested the MR and it resolves the issue for me. +1

  • First commit to issue fork.
  • Pipeline finished with Failed
    about 1 month ago
    Total: 178s
    #336301
  • πŸ‡΅πŸ‡±Poland alorenc Wolsztyn, πŸ‡΅πŸ‡±

    I set up a fresh instance and used the latest code from the module's 3.0.x branch, not from this specific merge request.

    Here’s what I tested:
    Logged in as two different users simultaneously.
    Started messaging between the two users.
    Throughout my testing, I didn’t observe any duplicate messages.

    In my case, I noticed the module triggers AJAX requests with the messageId parameter, which appears to be calculated in JavaScript. You can see the specific line in the code here:
    https://git.drupalcode.org/project/private_message/-/blame/3.0.x/js/priv...

    Could the issue be related to how the messageId is being calculated in your instance? It might be worth checking if the markup has been customized, as this could impact how the parameter is generated.

  • πŸ‡΅πŸ‡±Poland alorenc Wolsztyn, πŸ‡΅πŸ‡±
  • πŸ‡·πŸ‡΄Romania claudiu.cristea Arad πŸ‡·πŸ‡΄

    Marking as postponed, to get some feedback from @sagesolutions or other users

Production build 0.71.5 2024