Consider that the topic of a room has been removed when it's blank. (#4206)
This commit is contained in:
parent
c7f035fea5
commit
07dbb0b47a
2 changed files with 10 additions and 1 deletions
|
|
@ -63,7 +63,7 @@ class StateContentFormatter @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is OtherState.RoomTopic -> {
|
is OtherState.RoomTopic -> {
|
||||||
val hasRoomTopic = content.topic != null
|
val hasRoomTopic = content.topic?.isNotBlank() == true
|
||||||
when {
|
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_changed_by_you, content.topic)
|
||||||
senderIsYou && !hasRoomTopic -> sp.getString(R.string.state_event_room_topic_removed_by_you)
|
senderIsYou && !hasRoomTopic -> sp.getString(R.string.state_event_room_topic_removed_by_you)
|
||||||
|
|
|
||||||
|
|
@ -662,6 +662,7 @@ class DefaultRoomLastMessageFormatterTest {
|
||||||
val roomTopic = "New topic"
|
val roomTopic = "New topic"
|
||||||
val changedContent = StateContent("", OtherState.RoomTopic(roomTopic))
|
val changedContent = StateContent("", OtherState.RoomTopic(roomTopic))
|
||||||
val removedContent = StateContent("", OtherState.RoomTopic(null))
|
val removedContent = StateContent("", OtherState.RoomTopic(null))
|
||||||
|
val blankContent = StateContent("", OtherState.RoomTopic(""))
|
||||||
|
|
||||||
val youChangedRoomTopicEvent = createRoomEvent(sentByYou = true, senderDisplayName = null, content = changedContent)
|
val youChangedRoomTopicEvent = createRoomEvent(sentByYou = true, senderDisplayName = null, content = changedContent)
|
||||||
val youChangedRoomTopic = formatter.format(youChangedRoomTopicEvent, false)
|
val youChangedRoomTopic = formatter.format(youChangedRoomTopicEvent, false)
|
||||||
|
|
@ -678,6 +679,14 @@ class DefaultRoomLastMessageFormatterTest {
|
||||||
val someoneRemovedRoomTopicEvent = createRoomEvent(sentByYou = false, senderDisplayName = otherName, content = removedContent)
|
val someoneRemovedRoomTopicEvent = createRoomEvent(sentByYou = false, senderDisplayName = otherName, content = removedContent)
|
||||||
val someoneRemovedRoomTopic = formatter.format(someoneRemovedRoomTopicEvent, false)
|
val someoneRemovedRoomTopic = formatter.format(someoneRemovedRoomTopicEvent, false)
|
||||||
assertThat(someoneRemovedRoomTopic).isEqualTo("$otherName removed the room topic")
|
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
|
@Test
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue