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

Consider that the topic of a room has been removed when it's blank. #4209

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class StateContentFormatter @Inject constructor(
}
}
is OtherState.RoomTopic -> {
val hasRoomTopic = content.topic != null
val hasRoomTopic = content.topic?.isNotBlank() == true
when {
senderIsYou && hasRoomTopic -> sp.getString(R.string.state_event_room_topic_changed_by_you, content.topic)
senderIsYou && !hasRoomTopic -> sp.getString(R.string.state_event_room_topic_removed_by_you)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ class DefaultRoomLastMessageFormatterTest {
val roomTopic = "New topic"
val changedContent = StateContent("", OtherState.RoomTopic(roomTopic))
val removedContent = StateContent("", OtherState.RoomTopic(null))
val blankContent = StateContent("", OtherState.RoomTopic(""))

val youChangedRoomTopicEvent = createRoomEvent(sentByYou = true, senderDisplayName = null, content = changedContent)
val youChangedRoomTopic = formatter.format(youChangedRoomTopicEvent, false)
Expand All @@ -678,6 +679,14 @@ class DefaultRoomLastMessageFormatterTest {
val someoneRemovedRoomTopicEvent = createRoomEvent(sentByYou = false, senderDisplayName = otherName, content = removedContent)
val someoneRemovedRoomTopic = formatter.format(someoneRemovedRoomTopicEvent, false)
assertThat(someoneRemovedRoomTopic).isEqualTo("$otherName removed the room topic")

val youSetBlankRoomTopicEvent = createRoomEvent(sentByYou = true, senderDisplayName = null, content = blankContent)
val youSetBlankRoomTopic = formatter.format(youSetBlankRoomTopicEvent, false)
assertThat(youSetBlankRoomTopic).isEqualTo("You removed the room topic")

val someoneSetBlankRoomTopicEvent = createRoomEvent(sentByYou = false, senderDisplayName = otherName, content = blankContent)
val someoneSetBlankRoomTopic = formatter.format(someoneSetBlankRoomTopicEvent, false)
assertThat(someoneSetBlankRoomTopic).isEqualTo("$otherName removed the room topic")
}

@Test
Expand Down
Loading