Skip to content
Snippets Groups Projects
Unverified Commit bd677254 authored by Matthias Urhahn's avatar Matthias Urhahn Committed by GitHub
Browse files

Don't show last risk contact on "tracing disabled" card (DEV) #1776


* Don't show last risk contact when tracing is disabled.

* Add unit test.

Co-authored-by: default avatarRalf Gehrer <ralfgehrer@users.noreply.github.com>
parent cf141fb7
No related branches found
No related tags found
No related merge requests found
...@@ -135,11 +135,13 @@ data class TracingCardState( ...@@ -135,11 +135,13 @@ data class TracingCardState(
* only in the special case of increased risk as a positive contact is a * only in the special case of increased risk as a positive contact is a
* prerequisite for increased risk * prerequisite for increased risk
*/ */
fun getRiskContactLast(c: Context): String = if (riskState == INCREASED_RISK) { fun getRiskContactLast(c: Context): String = when {
val formattedDate = lastEncounterAt?.toLocalDate()?.toString(DateTimeFormat.mediumDate()) isTracingOff() -> ""
c.getString(R.string.risk_card_high_risk_most_recent_body, formattedDate) riskState == INCREASED_RISK -> {
} else { val formattedDate = lastEncounterAt?.toLocalDate()?.toString(DateTimeFormat.mediumDate())
"" c.getString(R.string.risk_card_high_risk_most_recent_body, formattedDate)
}
else -> ""
} }
/** /**
......
...@@ -211,6 +211,14 @@ class TracingCardStateTest : BaseTest() { ...@@ -211,6 +211,14 @@ class TracingCardStateTest : BaseTest() {
} }
} }
createInstance(
riskState = INCREASED_RISK,
lastEncounterAt = Instant.EPOCH,
tracingStatus = Status.TRACING_INACTIVE
).apply {
getRiskContactLast(context) shouldBe ""
}
createInstance(riskState = LOW_RISK).apply { createInstance(riskState = LOW_RISK).apply {
getRiskContactLast(context) shouldBe "" getRiskContactLast(context) shouldBe ""
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment