diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/expiration/ExpirationSettingsActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/expiration/ExpirationSettingsActivity.kt index 5a4178c2af..048cd1fd51 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/expiration/ExpirationSettingsActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/expiration/ExpirationSettingsActivity.kt @@ -62,7 +62,6 @@ import org.thoughtcrime.securesms.ui.Divider import org.thoughtcrime.securesms.ui.LocalExtraColors import org.thoughtcrime.securesms.ui.PreviewTheme import org.thoughtcrime.securesms.ui.ThemeResPreviewParameterProvider -import org.thoughtcrime.securesms.util.ConfigurationMessageUtilities import javax.inject.Inject import kotlin.math.min diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/expiration/ExpirationSettingsViewModel.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/expiration/ExpirationSettingsViewModel.kt index 65a121c699..9901915203 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/expiration/ExpirationSettingsViewModel.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/expiration/ExpirationSettingsViewModel.kt @@ -111,8 +111,18 @@ class ExpirationSettingsViewModel( } } + /** + * When enabling Disappearing Messages (for screens which provide the `Delete Type` options) the default `Timer` selection should be: + * Disappear After Read: `12 Hours` + * Disappear After Send: `1 Day` + * Legacy: `1 Day` + * */ override fun setType(type: ExpiryType) { - _state.update { it.copy(expiryMode = type.mode(0)) } + if (state.value.expiryType == type) return + + _state.update { + it.copy(expiryMode = type.defaultMode()) + } } override fun setTime(seconds: Long) { @@ -300,6 +310,11 @@ enum class ExpiryType(private val createMode: (Long) -> ExpiryMode) { AFTER_READ(ExpiryMode::AfterRead); fun mode(seconds: Long) = createMode(seconds) + + fun defaultMode() = when(this) { + AFTER_READ -> 43200L + else -> 86400L + }.let { mode(it) } } private val ExpiryMode.type: ExpiryType get() = when(this) {