Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replyTo are not updated if the original message is edited #6404

Merged
merged 16 commits into from
Jul 22, 2022

Conversation

Claire1817
Copy link
Contributor

@Claire1817 Claire1817 commented Jun 28, 2022

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Before printing a replied event, update it with the event from the DB.
I will do another PR for the rédaction.
Same solution implemented in iOs.

Motivation and context

Closes #5546

Screenshots / GIFs

repliedto_cXCxsYR6.mp4

Tests

Send a message, replied to the event and edit the first message.

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@Claire1817 Claire1817 marked this pull request as draft June 28, 2022 14:23
@@ -65,7 +65,7 @@ data class TimelineEvent(

init {
if (BuildConfig.DEBUG) {
assert(eventId == root.eventId)
// assert(eventId == root.eventId)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you add this line @bmarty ? If i keep it, it's not working

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.eventId should always have the same value than this.root.eventId. In which case this was not true on your side?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to use some code from LocalEventFactory to avoid the code duplication. In createEvent, a new eventId is created for the event.
In my case i don't know if i should use the past id even if i updated the relatedTo part ? or should i create a new id ? 🤔
Knowing i never update the DB, i juste update the object before print it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ganfra told me that i should keep the id.

@Claire1817 Claire1817 marked this pull request as ready for review June 29, 2022 08:53
@Claire1817 Claire1817 requested review from a team and yostyle and removed request for a team June 29, 2022 08:54
@Claire1817 Claire1817 changed the title If you reply to a redaction, the redacted text still appears replyTo are not updated if the original message is edited Jun 29, 2022
changelog.d/5546.bugfix Outdated Show resolved Hide resolved
@Claire1817 Claire1817 requested a review from ganfra July 6, 2022 15:27
(uiEchoManager?.decorateEventWithReactionUiEcho(it) ?: it)
uiEchoManager?.decorateEventWithReactionUiEcho(it)

if (it.isReply()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a name to the let scope param instead of using it

}

fun createEvent(roomId: String, type: String, content: Content?): Event {
fun createEvent(roomId: String, type: String, content: Content?, currentEventId: String? = null): Event {
Copy link
Member

@ganfra ganfra Jul 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels a bit hacky to use an eventId on the LocalEchoEventFactory, it should only gives Event with local.id.
I don't think we need a complete new Event but just a new Content. Create a method which returns the Content and uses this in both the Timeline and this Factory.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to do that and I failed to copy the Content of the root.
i did in timelinechunk:

val newEvent = it.root.copy(content = newContent)
it.copy(root = newEvent)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how you fail?
Also we have to be careful to copy all fields of Event, so we avoid loosing transient values:
Check here how we do that:

fun updateSentStateWithUiEcho(timelineEvent: TimelineEvent): TimelineEvent {
        if (timelineEvent.root.sendState.isSent()) return timelineEvent
        val inMemoryState = inMemorySendingStates[timelineEvent.eventId] ?: return timelineEvent
        // Timber.v("## ${clock.epochMillis()} Send event refresh echo with live state $inMemoryState from state ${element.root.sendState}")
        return timelineEvent.copy(
                root = timelineEvent.root.copyAll()
                        .also { it.sendState = inMemoryState }
        )
    }

@Claire1817 Claire1817 requested a review from ganfra July 7, 2022 12:29
@@ -573,6 +573,51 @@ internal class LocalEchoEventFactory @Inject constructor(
return clock.epochMillis()
}

fun createReplyTextContent(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use this in createReplyTextEvent

showInThread = false
)
val event = currentTimelineEvent.root
Event(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are missing the transient fields here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If i keep the transient fileds here, my message is not updated: the old version is keep.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because you are also copying the decrypted response :-)

@Claire1817 Claire1817 requested a review from ganfra July 18, 2022 07:56
Copy link
Member

@ganfra ganfra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

17.0% 17.0% Coverage
0.0% 0.0% Duplication

@Claire1817 Claire1817 enabled auto-merge (squash) July 22, 2022 13:15
@Claire1817 Claire1817 merged commit 99a906f into develop Jul 22, 2022
@Claire1817 Claire1817 deleted the cgizard/ISSUE-5546 branch July 22, 2022 13:35
ganfra pushed a commit that referenced this pull request Jul 27, 2022
@ganfra ganfra mentioned this pull request Jul 27, 2022
ganfra added a commit that referenced this pull request Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

If you reply to a redaction, the redacted text still appears
3 participants