get_new_messages loads all messages each ajax call

Created on 19 March 2024, 6 months ago
Updated 29 July 2024, about 1 month 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

Needs review

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
    6 months ago
    #126778
  • Pipeline finished with Failed
    6 months ago
    Total: 161s
    #126779
  • Status changed to Needs review 6 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 6 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 5 months ago
  • πŸ‡¨πŸ‡¦Canada sagesolutions

    Fixed the issue of reloading the message I just sent.

    Ready for review!

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

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

Production build 0.71.5 2024