diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/disappearingmessages/State.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/disappearingmessages/State.kt index f7c5a38e9d..eb4114ab54 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/disappearingmessages/State.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/disappearingmessages/State.kt @@ -18,7 +18,7 @@ data class State( val isSelfAdmin: Boolean = true, val address: Address? = null, val isNoteToSelf: Boolean = false, - val expiryMode: ExpiryMode = ExpiryMode.NONE, + val expiryMode: ExpiryMode? = null, val isNewConfigEnabled: Boolean = true, val persistedMode: ExpiryMode? = null, val showDebugOptions: Boolean = false @@ -30,8 +30,13 @@ data class State( val typeOptionsHidden get() = isNoteToSelf || (isGroup && isNewConfigEnabled) - val duration get() = expiryMode.duration - val expiryType get() = expiryMode.type + val nextType get() = when { + expiryType == ExpiryType.AFTER_READ -> ExpiryType.AFTER_READ + else -> ExpiryType.AFTER_SEND + } + + val duration get() = expiryMode?.duration + val expiryType get() = expiryMode?.type val isTimeOptionsEnabled = isNoteToSelf || isSelfAdmin && isNewConfigEnabled } diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/disappearingmessages/ui/Adapter.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/disappearingmessages/ui/Adapter.kt index 3900c06bcf..d4b3b0602a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/disappearingmessages/ui/Adapter.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/disappearingmessages/ui/Adapter.kt @@ -32,7 +32,7 @@ private fun State.timeOptions(): List? { // Don't show times card if we have a types card, and type is off. if (!typeOptionsHidden && expiryType == ExpiryType.NONE) return null - return expiryType.let { type -> + return nextType.let { type -> when (type) { ExpiryType.AFTER_READ -> afterReadTimes else -> afterSendTimes @@ -69,7 +69,7 @@ private fun debugModes(isDebug: Boolean, type: ExpiryType) = debugTimes(isDebug).map { type.mode(it.inWholeSeconds) } private fun State.debugOptions(): List = - debugModes(showDebugOptions, expiryType).map { timeOption(it, subtitle = GetString("for testing purposes")) } + debugModes(showDebugOptions, nextType).map { timeOption(it, subtitle = GetString("for testing purposes")) } // Standard list of available disappearing message times private val afterSendTimes = listOf(12.hours, 1.days, 7.days, 14.days) @@ -94,6 +94,6 @@ private fun State.timeOption( title = title, subtitle = subtitle, contentDescription = title, - selected = mode.duration == expiryMode.duration, + selected = mode.duration == expiryMode?.duration, enabled = isTimeOptionsEnabled )