mirror of
https://github.com/d4rken-org/capod.git
synced 2026-09-16 19:26:12 -04:00
Revert #605's cooldown-only mitigation in favor of the root-cause fix
@mvanhorn independently fixed #598 in #605 by no longer resetting the case cooldown on close, throttling the re-pop. We cherry-picked that commit above to keep his authorship/credit, but this PR instead removes the underlying lid-state flapping at its source (out-of-case pod's stale lid byte -> UNKNOWN), so the cooldown can keep resetting on close and a genuine close->reopen still shows the popup. Reverting his change here so the two approaches don't stack; thanks @mvanhorn for the parallel work.
This commit is contained in:
committed by
Matthias Urhahn
parent
2cce9ae56c
commit
af1b1b4249
@@ -290,8 +290,8 @@ class PopUpReaction @Inject constructor(
|
|||||||
DualApplePods.LidState.CLOSED -> CasePopUpDecision(
|
DualApplePods.LidState.CLOSED -> CasePopUpDecision(
|
||||||
shouldShow = false,
|
shouldShow = false,
|
||||||
shouldHide = true,
|
shouldHide = true,
|
||||||
shouldResetCooldown = false,
|
shouldResetCooldown = true,
|
||||||
reason = "Lid CLOSED, refreshing cooldown",
|
reason = "Lid CLOSED, resetting cooldown",
|
||||||
)
|
)
|
||||||
|
|
||||||
else -> CasePopUpDecision(
|
else -> CasePopUpDecision(
|
||||||
|
|||||||
@@ -36,11 +36,10 @@ class PopUpReactionLogicTest : BaseTest() {
|
|||||||
private fun evaluate(
|
private fun evaluate(
|
||||||
currentLidState: DualApplePods.LidState?,
|
currentLidState: DualApplePods.LidState?,
|
||||||
lastShownTime: Instant? = null,
|
lastShownTime: Instant? = null,
|
||||||
at: Instant = now,
|
|
||||||
) = popUpReaction.evaluateCasePopUp(
|
) = popUpReaction.evaluateCasePopUp(
|
||||||
currentLidState = currentLidState,
|
currentLidState = currentLidState,
|
||||||
lastShownTime = lastShownTime,
|
lastShownTime = lastShownTime,
|
||||||
now = at,
|
now = now,
|
||||||
cooldownDuration = cooldown,
|
cooldownDuration = cooldown,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -82,39 +81,11 @@ class PopUpReactionLogicTest : BaseTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `lid CLOSED - should NOT show, should hide, should NOT reset cooldown`() {
|
fun `lid CLOSED - should NOT show, should hide, should reset cooldown`() {
|
||||||
val decision = evaluate(currentLidState = DualApplePods.LidState.CLOSED)
|
val decision = evaluate(currentLidState = DualApplePods.LidState.CLOSED)
|
||||||
decision.shouldShow shouldBe false
|
decision.shouldShow shouldBe false
|
||||||
decision.shouldHide shouldBe true
|
decision.shouldHide shouldBe true
|
||||||
decision.shouldResetCooldown shouldBe false
|
decision.shouldResetCooldown shouldBe true
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `lid CLOSED followed by residual OPEN within cooldown - should NOT show`() {
|
|
||||||
val closeDecision = evaluate(currentLidState = DualApplePods.LidState.CLOSED)
|
|
||||||
closeDecision.shouldHide shouldBe true
|
|
||||||
closeDecision.shouldResetCooldown shouldBe false
|
|
||||||
|
|
||||||
val residualOpenDecision = evaluate(
|
|
||||||
currentLidState = DualApplePods.LidState.OPEN,
|
|
||||||
lastShownTime = now,
|
|
||||||
at = now.plusMillis(500),
|
|
||||||
)
|
|
||||||
residualOpenDecision.shouldShow shouldBe false
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `lid CLOSED then OPEN after cooldown elapsed - should show`() {
|
|
||||||
val closeDecision = evaluate(currentLidState = DualApplePods.LidState.CLOSED)
|
|
||||||
closeDecision.shouldHide shouldBe true
|
|
||||||
closeDecision.shouldResetCooldown shouldBe false
|
|
||||||
|
|
||||||
val reopenDecision = evaluate(
|
|
||||||
currentLidState = DualApplePods.LidState.OPEN,
|
|
||||||
lastShownTime = now,
|
|
||||||
at = now.plus(cooldown),
|
|
||||||
)
|
|
||||||
reopenDecision.shouldShow shouldBe true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user