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

Fix some quoted messages having 'null' message bodies #7532

Merged
merged 3 commits into from
Nov 14, 2022

Conversation

jmartinesp
Copy link
Member

@jmartinesp jmartinesp commented Nov 7, 2022

Type of change

  • Feature
  • Bugfix (SDK)
  • Technical
  • Other :

Content

LocalEchoEventFactory.createQuotedTextEvent incorrectly handled messages with no formatted text in quotes.

Motivation and context

Fixes #7530 .

Screenshots / GIFs

Tests

  • With Rich Text Editor disabled (using the default composer), type a message.
  • Quote this message.
  • Then enable markdown formatting (Settings > Preferences).
  • Quote the previous message using some MD formatting (bold, italic, etc.).
  • Create a new MD message, quote it too with no markdown in the new text.

No "null" text should appear and formatting should look good (correct new line after quote, etc.).

Tested devices

  • Physical
  • Emulator
  • OS version(s): API 29

Checklist

@jmartinesp jmartinesp requested a review from a team November 7, 2022 10:47
@jmartinesp jmartinesp self-assigned this Nov 7, 2022
@jmartinesp jmartinesp requested review from onurays and removed request for a team November 7, 2022 10:47

val plainTextBody = buildString {
val plainMessageParagraphs = quotedText?.split("\n\n".toRegex())?.dropLastWhile { it.isEmpty() }?.toTypedArray().orEmpty()
for ((i, paragraph) in plainMessageParagraphs.withIndex()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use plainMessageParagraphs.forEachIndexed { index, paragraph -> } instead?

Copy link
Contributor

@onurays onurays left a comment

Choose a reason for hiding this comment

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

LGTM. This is a sensitive fix. Thank you for adding tests.

@jmartinesp jmartinesp force-pushed the fix/quoted-messages-with-null-bodies branch from f88f394 to 4e710af Compare November 9, 2022 12:01
@jmartinesp jmartinesp enabled auto-merge (squash) November 9, 2022 12:01
@jmartinesp jmartinesp force-pushed the fix/quoted-messages-with-null-bodies branch from 4e710af to 45da708 Compare November 14, 2022 10:19
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

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

84.7% 84.7% Coverage
0.0% 0.0% Duplication

@jmartinesp jmartinesp merged commit a476544 into develop Nov 14, 2022
@jmartinesp jmartinesp deleted the fix/quoted-messages-with-null-bodies branch November 14, 2022 11:01
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.

Reply with cite message results in nullnull text
2 participants