Skip to content

Properly format lastMessage when it belongs to a poll. #1387

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

Merged
merged 4 commits into from
Sep 21, 2023

Conversation

julioromano
Copy link

Takes care of properly formatting a room's last message when it belongs to a poll.

NB: Polls still aren't exposed as a room's last_message from the rust SDK, so this code won't actually run yet. This will happen after integrating rust SDK version 0.1.57 which includes: matrix-org/matrix-rust-sdk#2580

@julioromano julioromano requested a review from a team as a code owner September 20, 2023 11:25
@julioromano julioromano self-assigned this Sep 20, 2023
@julioromano julioromano requested review from bmarty and removed request for a team September 20, 2023 11:25
@codecov
Copy link

codecov bot commented Sep 20, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.01% 🎉

Comparison is base (0c10432) 57.97% compared to head (00e8e94) 57.99%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1387      +/-   ##
===========================================
+ Coverage    57.97%   57.99%   +0.01%     
===========================================
  Files         1126     1126              
  Lines        29794    29804      +10     
  Branches      6052     6052              
===========================================
+ Hits         17274    17285      +11     
  Misses        9931     9931              
+ Partials      2589     2588       -1     
Files Changed Coverage Δ
...tformatter/impl/DefaultRoomLastMessageFormatter.kt 96.87% <100.00%> (+1.71%) ⬆️
...d/libraries/matrix/test/room/RoomSummaryFixture.kt 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 20, 2023

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/EAS3cP

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

LGTM, thanks.

@@ -95,7 +95,9 @@ class DefaultRoomLastMessageFormatter @Inject constructor(
is StateContent -> {
stateContentFormatter.format(content, senderDisplayName, isOutgoing, RenderingMode.RoomList)
}
is PollContent, // TODO Polls: handle last message
is PollContent -> {
prefixIfNeeded(content.question, senderDisplayName, isDmRoom)
Copy link
Member

Choose a reason for hiding this comment

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

Don't we want to prefix the question with something like "Poll: ", or even better display a picto?

Copy link
Author

@julioromano julioromano Sep 20, 2023

Choose a reason for hiding this comment

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

Nice idea, forwarded the question to design: element-hq/element-meta#2048 (comment)
Not sure though how easy it is to include an icon/image here with the current code that handle the last messages.

@julioromano julioromano force-pushed the julioromano/polls_in_room_summary branch 2 times, most recently from 726b9e3 to 4996643 Compare September 21, 2023 07:11
@julioromano
Copy link
Author

Prefixed summary with "Poll: " and added unit tests.

@julioromano julioromano enabled auto-merge (squash) September 21, 2023 07:12
@julioromano julioromano force-pushed the julioromano/polls_in_room_summary branch from 4996643 to aeecd19 Compare September 21, 2023 07:41
@@ -58,6 +59,7 @@ import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.annotation.Config

@Suppress("LargeClass")
Copy link
Author

Choose a reason for hiding this comment

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

@bmarty I had to add this, is it ok?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, thanks!

@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

No Coverage information No Coverage information
0.0% 0.0% Duplication

@julioromano julioromano merged commit e4c78a2 into develop Sep 21, 2023
@julioromano julioromano deleted the julioromano/polls_in_room_summary branch September 21, 2023 13:20
val pollContent = aPollContent()

val mineContentEvent = createRoomEvent(sentByYou = true, senderDisplayName = "Alice", content = pollContent)
Truth.assertThat(formatter.format(mineContentEvent, false).toString()).isEqualTo("Alice: Poll: Do you like polls?")
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for adding tests. At some point we should revisit the last message rendering when it's sent by the current user. WhatsApp prefixes by You: in groups, nothing in DM, and on Element Android we just omit the sender name (IIRC, not 100% sure)

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Thanks!

julioromano pushed a commit that referenced this pull request Sep 21, 2023
- Enables polls in room summaries from #1387
- Accommodates a few breaking changes
julioromano pushed a commit that referenced this pull request Sep 21, 2023
- Enables polls in room summaries from #1387
- Accommodates a few breaking changes
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.

2 participants