fix(llc): reply being considered deleted if a new message was typed inside its thread #1866
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Submit a pull request
CLA
Description of the pull request
Problem Description
We encountered a bug in our messaging feature where quoted messages were inadvertently marked as deleted when replying within a thread. This behavior was linked to the
updateMessage
method's logic, which inaccurately managed the state of quoted messages during updates, particularly in thread reply scenarios.Root Cause Analysis
The core of the issue was found in the original implementation of the
updateMessage
method within theChannel
class. The method indiscriminately updated quoted messages whenever an updating message's ID matched that of a quoted message, leading to quoted messages being marked as deleted by mistake, simply due to their reference in updates or replies.Solution Implemented
The fix involved a strategic refactor of the
updateMessage
method to ensure updates to messages, especially regarding quoted messages, are handled with precision, maintaining the integrity of quoted messages unless explicitly deleted. The following key improvements were made:Preserving Quoted Messages: Enhanced the method to verify if an updating message references a quoted message without intent to delete, preserving the quoted message's original state in such instances.
Refined Deletion Logic: Refined the approach to marking a quoted message as deleted, ensuring this only occurs with clear indications of the quoted message's deletion (e.g., when the message's type is 'deleted').
Code Readability and Maintainability: Restructured the method for improved readability, segregating concerns clearly and documenting with comments.
Separate Handling for Pinned Messages: Segregated the pinned messages handling logic into its own method, simplifying the
updateMessage
method.How it was
Simulator.Screen.Recording.-.iPhone.SE.3rd.generation.-.2024-02-28.at.17.43.49.mp4
How it is now
Simulator.Screen.Recording.-.iPhone.SE.3rd.generation.-.2024-02-28.at.17.26.29.mp4