Skip to content

Commit

Permalink
Merge pull request EventFahrplan#603 from EventFahrplan/shift-title-e…
Browse files Browse the repository at this point in the history
…mpty

Display session subtitle as title if the latter is empty.
  • Loading branch information
johnjohndoe authored Jan 10, 2024
2 parents c7d8c92 + d43a200 commit 5903404
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ fun SessionNetworkModel.toSessionAppModel(): Session {
}

fun Session.sanitize(): Session {
if (title.isEmpty() && subtitle.isNotEmpty()) {
title = subtitle
subtitle = ""
}
if (title == subtitle) {
subtitle = ""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,19 @@ class SessionExtensionsTest {
assertThat(session.toHighlightDatabaseModel()).isEqualTo(highlight)
}

@Test
fun sanitizeWithEmptyTitleAndSubtitle() {
val session = Session("").apply {
subtitle = "Lorem ipsum"
title = ""
}.sanitize()
val expected = Session("").apply {
subtitle = ""
title = "Lorem ipsum"
}
assertThat(session).isEqualTo(expected)
}

@Test
fun sanitizeWithSameTitleAndSubtitle() {
val session = Session("").apply {
Expand Down Expand Up @@ -271,10 +284,12 @@ class SessionExtensionsTest {
val session = Session("").apply {
speakers = listOf("Luke Skywalker")
subtitle = "Luke Skywalker"
title = "Some title"
}.sanitize()
val expected = Session("").apply {
speakers = listOf("Luke Skywalker")
subtitle = ""
title = "Some title"
}
assertThat(session).isEqualTo(expected)
}
Expand All @@ -284,10 +299,12 @@ class SessionExtensionsTest {
val session = Session("").apply {
speakers = listOf("Darth Vader")
subtitle = "Lorem ipsum"
title = "Some title"
}.sanitize()
val expected = Session("").apply {
speakers = listOf("Darth Vader")
subtitle = "Lorem ipsum"
title = "Some title"
}
assertThat(session).isEqualTo(expected)
}
Expand Down

0 comments on commit 5903404

Please sign in to comment.