Skip to content

Last read message not updated due to deleted messages #6742

Open

Description

When a message is deleted a system message with type message_deleted is added; those messages are not rendered. When the last read message is updated it is checked if the first unread message was already seen, and if it is not then the last read message is not updated. As message_deleted messages are not rendered, if the last read message is set to a message_deleted then the first unread message will never be found and thus the last read message will not be updated anymore.

This can happen if a conversation is explicitly marked as read after a message was deleted. But it can happen too in other ways.

When the last read message is updated due to being at the bottom of the chat the last read message is just cleared, that is, it is set to the last message in the conversation. Therefore if a conversation is just opened and scrolled to the bottom after a message was deleted the last read message will be cleared, setting the message_deleted as the last read message and preventing it from being updated anymore.

Note that even if the chat is at the bottom the last read message is cleared only if the last unread message was already seen. This leads to other interesting conditions for the bug to be triggered.

For example, in the scenario 3 below, the bug only appears if the unread marker is still visible when the previous message is deleted. If the unread marker was already removed (for example, by unfocusing and focusing the window again) the bug will not appear, as the last read message will be set to the last visible message (the one sent by the other user), but as this message is the last one it is not marked as seen. As the message is not marked as seen when the message_deleted message is added the last read message is not cleared, and as the last read message is not cleared message_deleted is not set as the last read message, which prevents the bug from appearing.

How to test (scenario 1)

  • Create a conversation and add another user
  • In a private window, open the conversation with the other user
  • In the original window, write a lot of messages (so they do not fit in the view and a scroll bar appears)
  • In the private window, scroll to the bottom and wait until the unread count is cleared
  • Change to another conversation
  • In the original window, write a message and then delete it
  • In the private window, wait until {actor} deleted a message appears in the conversation list
  • Mark the conversation as read (without even joining it)
  • In the original window, write another message
  • In the private window, open the conversation again

Expected result

The last read message is updated (the unread count in the sidebar is cleared)

Actual result

The last read message is not updated (the unread count in the sidebar is not cleared)

How to test (scenario 2)

  • Create a conversation and add another user
  • In a private window, open the conversation with the other user
  • In the original window, write a lot of messages (so they do not fit in the view and a scroll bar appears)
  • In the private window, scroll to the bottom and wait until the unread count is cleared
  • Change to another conversation
  • In the original window, write a message and then delete it
  • In the private window, open the conversation again
  • Change to another conversation
  • In the original window, write another message
  • In the private window, open the conversation again

Expected result

The last read message is updated (the unread count in the sidebar is cleared)

Actual result

The last read message is not updated (the unread count in the sidebar is not cleared)

How to test (scenario 3)

  • Create a conversation and add another user
  • In a private window, open the conversation with the other user
  • In the original window, write a lot of messages (so they do not fit in the view and a scroll bar appears)
  • In the private window, scroll to the bottom and wait until the unread count is cleared
  • Write a message
  • In the original window, write a message
  • In the private window, delete the previous message
  • In the original window, write another message
  • In the private window, reload the conversation

Expected result

The last read message is updated (the unread count in the sidebar is cleared)

Actual result

The last read message is not updated (the unread count in the sidebar is not cleared)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

  • Status

    📄 To do (~10 entries)

Relationships

None yet

Development

No branches or pull requests

Issue actions