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 6d4307dbbf..5c8b8c54de 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 @@ -18,12 +18,12 @@ import kotlinx.coroutines.launch import network.loki.messenger.BuildConfig import network.loki.messenger.R import network.loki.messenger.databinding.ActivityExpirationSettingsBinding +import network.loki.messenger.libsession_util.util.ExpiryMode import org.session.libsession.messaging.messages.ExpirationConfiguration -import org.session.libsignal.protos.SignalServiceProtos.Content.ExpirationType import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity import org.thoughtcrime.securesms.database.RecipientDatabase import org.thoughtcrime.securesms.database.ThreadDatabase -import org.thoughtcrime.securesms.preferences.RadioOption +import org.thoughtcrime.securesms.preferences.ExpirationRadioOption import org.thoughtcrime.securesms.preferences.RadioOptionAdapter import org.thoughtcrime.securesms.util.ConfigurationMessageUtilities import javax.inject.Inject @@ -45,19 +45,25 @@ class ExpirationSettingsActivity: PassphraseRequiredActionBarActivity() { private val viewModel: ExpirationSettingsViewModel by viewModels { val afterReadOptions = resources.getIntArray(R.array.read_expiration_time_values).map(Int::toString) .zip(resources.getStringArray(R.array.read_expiration_time_names)) { value, name -> - RadioOption(value, name, getString(R.string.AccessibilityId_time_option)) + ExpirationRadioOption(ExpiryMode.AfterRead(value.toLong()), name, getString(R.string.AccessibilityId_time_option)) } val afterSendOptions = resources.getIntArray(R.array.send_expiration_time_values).map(Int::toString) .zip(resources.getStringArray(R.array.send_expiration_time_names)) { value, name -> - RadioOption(value, name, getString(R.string.AccessibilityId_time_option)) + ExpirationRadioOption(ExpiryMode.AfterSend(value.toLong()), name, getString(R.string.AccessibilityId_time_option)) } viewModelFactory.create(threadId, mayAddTestExpiryOption(afterReadOptions), mayAddTestExpiryOption(afterSendOptions)) } - private fun mayAddTestExpiryOption(expiryOptions: List): List { + private fun mayAddTestExpiryOption(expiryOptions: List): List { return if (BuildConfig.DEBUG) { val options = expiryOptions.toMutableList() - options.add(1, RadioOption("60", "1 Minute (for testing purposes)")) + val added = when (options.first().value) { + is ExpiryMode.AfterRead -> ExpiryMode.AfterRead(60) + is ExpiryMode.AfterSend -> ExpiryMode.AfterSend(60) + is ExpiryMode.Legacy -> ExpiryMode.Legacy(60) + ExpiryMode.NONE -> ExpiryMode.NONE // shouldn't happen + } + options.add(1, ExpirationRadioOption(added, "1 Minute (for testing purposes)")) options } else expiryOptions } @@ -129,7 +135,7 @@ class ExpirationSettingsActivity: PassphraseRequiredActionBarActivity() { lifecycleScope.launch { repeatOnLifecycle(Lifecycle.State.STARTED) { viewModel.selectedExpirationType.collect { type -> - val position = deleteTypeOptions.indexOfFirst { it.value.toIntOrNull() == type } + val position = deleteTypeOptions.indexOfFirst { it.value == type } deleteTypeOptionAdapter.setSelectedPosition(max(0, position)) } } @@ -170,32 +176,61 @@ class ExpirationSettingsActivity: PassphraseRequiredActionBarActivity() { Toast.makeText(this, message, Toast.LENGTH_SHORT).show() } - private fun getDeleteOptions(): List { + private fun getDeleteOptions(): List { if (!viewModel.uiState.value.showExpirationTypeSelector) return emptyList() - val deleteTypeOptions = mutableListOf() + val deleteTypeOptions = mutableListOf() if (ExpirationConfiguration.isNewConfigEnabled) { if (viewModel.recipient.value?.isContactRecipient == true && viewModel.recipient.value?.isLocalNumber == false) { deleteTypeOptions.addAll( listOf( - RadioOption( - value = "-1", + ExpirationRadioOption( + value = ExpiryMode.NONE, title = getString(R.string.expiration_off), - enabled = viewModel.uiState.value.isSelfAdmin, contentDescription = getString(R.string.AccessibilityId_disable_disappearing_messages) ), - RadioOption( - value = ExpirationType.DELETE_AFTER_READ_VALUE.toString(), + ExpirationRadioOption( + value = ExpiryMode.AfterRead(0), title = getString(R.string.expiration_type_disappear_after_read), subtitle = getString(R.string.expiration_type_disappear_after_read_description), - enabled = viewModel.uiState.value.isSelfAdmin, contentDescription = getString(R.string.AccessibilityId_disappear_after_read_option) ), - RadioOption( - value = ExpirationType.DELETE_AFTER_SEND_VALUE.toString(), + ExpirationRadioOption( + value = ExpiryMode.AfterSend(0), + title = getString(R.string.expiration_type_disappear_after_send), + subtitle = getString(R.string.expiration_type_disappear_after_send_description), + contentDescription = getString(R.string.AccessibilityId_disappear_after_send_option) + ) + ) + ) + } else if (viewModel.recipient.value?.isLocalNumber == true) { + deleteTypeOptions.addAll( + listOf( + ExpirationRadioOption( + value = ExpiryMode.NONE, + title = getString(R.string.expiration_off), + contentDescription = getString(R.string.AccessibilityId_disable_disappearing_messages) + ), + ExpirationRadioOption( + value = ExpiryMode.AfterSend(0), + title = getString(R.string.expiration_type_disappear_after_send), + subtitle = getString(R.string.expiration_type_disappear_after_send_description), + contentDescription = getString(R.string.AccessibilityId_disappear_after_send_option) + ) + ) + ) + } else if (viewModel.recipient.value?.isClosedGroupRecipient == true) { + deleteTypeOptions.addAll( + listOf( + ExpirationRadioOption( + value = ExpiryMode.NONE, + title = getString(R.string.expiration_off), + contentDescription = getString(R.string.AccessibilityId_disable_disappearing_messages) + ), + ExpirationRadioOption( + value = ExpiryMode.AfterSend(0), title = getString(R.string.expiration_type_disappear_after_send), subtitle = getString(R.string.expiration_type_disappear_after_send_description), - enabled = viewModel.uiState.value.isSelfAdmin, contentDescription = getString(R.string.AccessibilityId_disappear_after_send_option) ) ) @@ -205,25 +240,25 @@ class ExpirationSettingsActivity: PassphraseRequiredActionBarActivity() { if (viewModel.recipient.value?.isContactRecipient == true && viewModel.recipient.value?.isLocalNumber == false) { deleteTypeOptions.addAll( listOf( - RadioOption( - value = "-1", + ExpirationRadioOption( + value = ExpiryMode.NONE, title = getString(R.string.expiration_off), contentDescription = getString(R.string.AccessibilityId_disable_disappearing_messages) ), - RadioOption( - value = "0", + ExpirationRadioOption( + value = ExpiryMode.Legacy(0), title = getString(R.string.expiration_type_disappear_legacy), subtitle = getString(R.string.expiration_type_disappear_legacy_description) ), - RadioOption( - value = ExpirationType.DELETE_AFTER_READ_VALUE.toString(), + ExpirationRadioOption( + value = ExpiryMode.AfterRead(0), title = getString(R.string.expiration_type_disappear_after_read), subtitle = getString(R.string.expiration_type_disappear_after_read_description), enabled = false, contentDescription = getString(R.string.AccessibilityId_disappear_after_read_option) ), - RadioOption( - value = ExpirationType.DELETE_AFTER_SEND_VALUE.toString(), + ExpirationRadioOption( + value = ExpiryMode.AfterSend(0), title = getString(R.string.expiration_type_disappear_after_send), subtitle = getString(R.string.expiration_type_disappear_after_send_description), enabled = false, @@ -234,14 +269,14 @@ class ExpirationSettingsActivity: PassphraseRequiredActionBarActivity() { } else { deleteTypeOptions.addAll( listOf( - RadioOption(value = "-1", title = getString(R.string.expiration_off)), - RadioOption( - value = "0", + ExpirationRadioOption(value = ExpiryMode.NONE, title = getString(R.string.expiration_off)), + ExpirationRadioOption( + value = ExpiryMode.Legacy(0), title = getString(R.string.expiration_type_disappear_legacy), subtitle = getString(R.string.expiration_type_disappear_legacy_description) ), - RadioOption( - value = ExpirationType.DELETE_AFTER_SEND_VALUE.toString(), + ExpirationRadioOption( + value = ExpiryMode.AfterSend(0), title = getString(R.string.expiration_type_disappear_after_send), subtitle = getString(R.string.expiration_type_disappear_after_send_description), enabled = false, @@ -258,7 +293,7 @@ class ExpirationSettingsActivity: PassphraseRequiredActionBarActivity() { setSupportActionBar(binding.toolbar) val actionBar = supportActionBar ?: return actionBar.title = getString(R.string.activity_expiration_settings_title) - actionBar.subtitle = if (viewModel.selectedExpirationType.value == ExpirationType.DELETE_AFTER_SEND.number) { + actionBar.subtitle = if (viewModel.selectedExpirationType.value is ExpiryMode.AfterSend) { getString(R.string.activity_expiration_settings_subtitle_sent) } else { getString(R.string.activity_expiration_settings_subtitle) 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 b887ea839c..9c6ae84f4b 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 @@ -19,20 +19,17 @@ import org.session.libsession.messaging.sending_receiving.MessageSender import org.session.libsession.snode.SnodeAPI import org.session.libsession.utilities.SSKEnvironment.MessageExpirationManagerProtocol import org.session.libsession.utilities.TextSecurePreferences -import org.session.libsession.utilities.expiryType import org.session.libsession.utilities.recipients.Recipient -import org.session.libsession.utilities.typeRadioIndex -import org.session.libsignal.protos.SignalServiceProtos.Content.ExpirationType import org.thoughtcrime.securesms.database.GroupDatabase import org.thoughtcrime.securesms.database.Storage import org.thoughtcrime.securesms.database.ThreadDatabase -import org.thoughtcrime.securesms.preferences.RadioOption +import org.thoughtcrime.securesms.preferences.ExpirationRadioOption import kotlin.reflect.KClass class ExpirationSettingsViewModel( private val threadId: Long, - private val afterReadOptions: List, - private val afterSendOptions: List, + private val afterReadOptions: List, + private val afterSendOptions: List, private val textSecurePreferences: TextSecurePreferences, private val messageExpirationManager: MessageExpirationManagerProtocol, private val threadDb: ThreadDatabase, @@ -48,14 +45,14 @@ class ExpirationSettingsViewModel( private val _recipient = MutableStateFlow(null) val recipient: StateFlow = _recipient - private val _selectedExpirationType = MutableStateFlow(-1) - val selectedExpirationType: StateFlow = _selectedExpirationType + private val _selectedExpirationType: MutableStateFlow = MutableStateFlow(ExpiryMode.NONE) + val selectedExpirationType: StateFlow = _selectedExpirationType private val _selectedExpirationTimer = MutableStateFlow(afterSendOptions.firstOrNull()) - val selectedExpirationTimer: StateFlow = _selectedExpirationTimer + val selectedExpirationTimer: StateFlow = _selectedExpirationTimer - private val _expirationTimerOptions = MutableStateFlow>(emptyList()) - val expirationTimerOptions: StateFlow> = _expirationTimerOptions + private val _expirationTimerOptions = MutableStateFlow>(emptyList()) + val expirationTimerOptions: StateFlow> = _expirationTimerOptions init { // SETUP @@ -70,24 +67,26 @@ class ExpirationSettingsViewModel( _uiState.update { currentUiState -> currentUiState.copy( isSelfAdmin = groupInfo == null || groupInfo.admins.any{ it.serialize() == textSecurePreferences.getLocalNumber() }, - showExpirationTypeSelector = !ExpirationConfiguration.isNewConfigEnabled || (recipient?.isContactRecipient == true && !recipient.isLocalNumber) + showExpirationTypeSelector = true ) } _selectedExpirationType.value = if (ExpirationConfiguration.isNewConfigEnabled) { - expirationType.typeRadioIndex() + expirationType ?: ExpiryMode.NONE } else { - if (expirationType != null && expirationType != ExpiryMode.NONE) 0 else -1 + if (expirationType != null && expirationType != ExpiryMode.NONE) + ExpiryMode.Legacy(expirationType.expirySeconds) + else ExpiryMode.NONE } _selectedExpirationTimer.value = when(expirationType) { - is ExpiryMode.AfterSend -> afterSendOptions.find { it.value.toIntOrNull() == expirationType.expirySeconds.toInt() } - is ExpiryMode.AfterRead -> afterReadOptions.find { it.value.toIntOrNull() == expirationType.expirySeconds.toInt() } + is ExpiryMode.AfterSend -> afterSendOptions.find { it.value == expirationType } + is ExpiryMode.AfterRead -> afterReadOptions.find { it.value == expirationType } else -> afterSendOptions.firstOrNull() } } selectedExpirationType.mapLatest { when (it) { - 0, ExpirationType.DELETE_AFTER_SEND.number -> afterSendOptions - ExpirationType.DELETE_AFTER_READ.number -> afterReadOptions + is ExpiryMode.Legacy, is ExpiryMode.AfterSend -> afterSendOptions + is ExpiryMode.AfterRead -> afterReadOptions else -> emptyList() } }.onEach { options -> @@ -100,12 +99,12 @@ class ExpirationSettingsViewModel( }.launchIn(viewModelScope) } - fun onExpirationTypeSelected(option: RadioOption) { - _selectedExpirationType.value = option.value.toIntOrNull() ?: -1 + fun onExpirationTypeSelected(option: ExpirationRadioOption) { + _selectedExpirationType.value = option.value _selectedExpirationTimer.value = _expirationTimerOptions.value.firstOrNull() } - fun onExpirationTimerSelected(option: RadioOption) { + fun onExpirationTimerSelected(option: ExpirationRadioOption) { _selectedExpirationTimer.value = option } @@ -116,15 +115,9 @@ class ExpirationSettingsViewModel( } fun onSetClick() = viewModelScope.launch { - var typeValue = _selectedExpirationType.value - if (typeValue == 0) { - typeValue = ExpirationType.DELETE_AFTER_READ_VALUE - } - val expirationTimer = _selectedExpirationTimer.value?.value?.toIntOrNull() ?: 0 - val expiryTypeClass = typeValue.expiryType() - val expiryMode = expiryTypeClass?.withTime(expirationTimer.toLong()) + val expiryMode = _selectedExpirationTimer.value?.value ?: ExpiryMode.NONE val address = recipient.value?.address - if (address == null || (expirationConfig?.expiryMode?.javaClass == expiryTypeClass && expirationConfig?.expiryMode?.expirySeconds?.toInt() == expirationTimer)) { + if (address == null || (expirationConfig?.expiryMode != expiryMode)) { _uiState.update { it.copy(settingsSaved = false) } @@ -134,7 +127,7 @@ class ExpirationSettingsViewModel( val expiryChangeTimestampMs = SnodeAPI.nowWithOffset storage.setExpirationConfiguration(ExpirationConfiguration(threadId, expiryMode, expiryChangeTimestampMs)) - val message = ExpirationTimerUpdate(expirationTimer) + val message = ExpirationTimerUpdate(expiryMode.expirySeconds.toInt()) message.sender = textSecurePreferences.getLocalNumber() message.recipient = address.serialize() message.sentTimestamp = expiryChangeTimestampMs @@ -150,16 +143,16 @@ class ExpirationSettingsViewModel( interface AssistedFactory { fun create( threadId: Long, - @Assisted("afterRead") afterReadOptions: List, - @Assisted("afterSend") afterSendOptions: List + @Assisted("afterRead") afterReadOptions: List, + @Assisted("afterSend") afterSendOptions: List ): Factory } @Suppress("UNCHECKED_CAST") class Factory @AssistedInject constructor( @Assisted private val threadId: Long, - @Assisted("afterRead") private val afterReadOptions: List, - @Assisted("afterSend") private val afterSendOptions: List, + @Assisted("afterRead") private val afterReadOptions: List, + @Assisted("afterSend") private val afterSendOptions: List, private val textSecurePreferences: TextSecurePreferences, private val messageExpirationManager: MessageExpirationManagerProtocol, private val threadDb: ThreadDatabase, diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/RadioOptionAdapter.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/RadioOptionAdapter.kt index 52cf6ee4ec..64ddd3a04d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/RadioOptionAdapter.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/RadioOptionAdapter.kt @@ -9,24 +9,26 @@ import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView import network.loki.messenger.R import network.loki.messenger.databinding.ItemSelectableBinding +import network.loki.messenger.libsession_util.util.ExpiryMode import org.thoughtcrime.securesms.mms.GlideApp +import java.util.Objects -class RadioOptionAdapter( +class RadioOptionAdapter( private var selectedOptionPosition: Int = 0, - private val onClickListener: (RadioOption) -> Unit -) : ListAdapter(RadioOptionDiffer()) { + private val onClickListener: (RadioOption) -> Unit +) : ListAdapter, RadioOptionAdapter.ViewHolder>(RadioOptionDiffer()) { - class RadioOptionDiffer: DiffUtil.ItemCallback() { - override fun areItemsTheSame(oldItem: RadioOption, newItem: RadioOption) = oldItem.title == newItem.title - override fun areContentsTheSame(oldItem: RadioOption, newItem: RadioOption) = oldItem.value == newItem.value + class RadioOptionDiffer: DiffUtil.ItemCallback>() { + override fun areItemsTheSame(oldItem: RadioOption, newItem: RadioOption) = oldItem.title == newItem.title + override fun areContentsTheSame(oldItem: RadioOption, newItem: RadioOption) = Objects.equals(oldItem.value,newItem.value) } - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val itemView = LayoutInflater.from(parent.context).inflate(R.layout.item_selectable, parent, false) - return ViewHolder(itemView) + return ViewHolder(itemView) } - override fun onBindViewHolder(holder: ViewHolder, position: Int) { + override fun onBindViewHolder(holder: ViewHolder, position: Int) { val option = getItem(position) val isSelected = position == selectedOptionPosition holder.bind(option, isSelected) { @@ -41,12 +43,12 @@ class RadioOptionAdapter( notifyDataSetChanged() } - class ViewHolder(itemView: View): RecyclerView.ViewHolder(itemView) { + class ViewHolder(itemView: View): RecyclerView.ViewHolder(itemView) { val glide = GlideApp.with(itemView) val binding = ItemSelectableBinding.bind(itemView) - fun bind(option: RadioOption, isSelected: Boolean, toggleSelection: (RadioOption) -> Unit) { + fun bind(option: RadioOption, isSelected: Boolean, toggleSelection: (RadioOption) -> Unit) { val alpha = if (option.enabled) 1f else 0.5f binding.root.isEnabled = option.enabled binding.root.contentDescription = option.contentDescription @@ -66,10 +68,36 @@ class RadioOptionAdapter( } -data class RadioOption( - val value: String, +sealed class RadioOption( + val value: T, val title: String, val subtitle: String? = null, val enabled: Boolean = true, val contentDescription: String = "" ) + +class StringRadioOption(value: String, + title: String, + subtitle: String? = null, + enabled: Boolean = true, + contentDescription: String = ""): RadioOption( + value, + title, + subtitle, + enabled, + contentDescription +) + +class ExpirationRadioOption( + value: ExpiryMode, + title: String, + subtitle: String? = null, + enabled: Boolean = true, + contentDescription: String = "" +): RadioOption( + value, + title, + subtitle, + enabled, + contentDescription +) diff --git a/libsession-util/src/main/java/network/loki/messenger/libsession_util/util/ExpiryMode.kt b/libsession-util/src/main/java/network/loki/messenger/libsession_util/util/ExpiryMode.kt index 58e98a4392..aa1d9a6cfc 100644 --- a/libsession-util/src/main/java/network/loki/messenger/libsession_util/util/ExpiryMode.kt +++ b/libsession-util/src/main/java/network/loki/messenger/libsession_util/util/ExpiryMode.kt @@ -2,6 +2,7 @@ package network.loki.messenger.libsession_util.util sealed class ExpiryMode(val expirySeconds: Long) { object NONE: ExpiryMode(0) + class Legacy(seconds: Long): ExpiryMode(seconds) // after read class AfterSend(seconds: Long): ExpiryMode(seconds) class AfterRead(seconds: Long): ExpiryMode(seconds) } \ No newline at end of file diff --git a/libsession/src/main/java/org/session/libsession/messaging/messages/ExpirationConfiguration.kt b/libsession/src/main/java/org/session/libsession/messaging/messages/ExpirationConfiguration.kt index a2f5e2ab8d..fc14fb8044 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/messages/ExpirationConfiguration.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/messages/ExpirationConfiguration.kt @@ -10,8 +10,7 @@ data class ExpirationConfiguration( val isEnabled = expiryMode != null && expiryMode.expirySeconds > 0 companion object { - val isNewConfigEnabled = false /* TODO: System.currentTimeMillis() > 1_676_851_200_000 // 13/02/2023 */ - const val LAST_READ_TEST = 1673587663000L + val isNewConfigEnabled = true /* TODO: System.currentTimeMillis() > 1_676_851_200_000 // 13/02/2023 */ } } diff --git a/libsession/src/main/java/org/session/libsession/messaging/messages/Message.kt b/libsession/src/main/java/org/session/libsession/messaging/messages/Message.kt index c82eb2d128..646c744e38 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/messages/Message.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/messages/Message.kt @@ -70,7 +70,7 @@ abstract class Message { when (expiryMode) { is ExpiryMode.AfterSend -> expirationType = ExpirationType.DELETE_AFTER_SEND is ExpiryMode.AfterRead -> expirationType = ExpirationType.DELETE_AFTER_READ - ExpiryMode.NONE -> { /* do nothing */ } + is ExpiryMode.Legacy, ExpiryMode.NONE -> { /* do nothing */ } } } } diff --git a/libsession/src/main/java/org/session/libsession/utilities/ExpirationUtilities.kt b/libsession/src/main/java/org/session/libsession/utilities/ExpirationUtilities.kt index 4941e0ae52..77287b4dc2 100644 --- a/libsession/src/main/java/org/session/libsession/utilities/ExpirationUtilities.kt +++ b/libsession/src/main/java/org/session/libsession/utilities/ExpirationUtilities.kt @@ -8,6 +8,7 @@ fun ExpiryMode?.typeRadioIndex(): Int { return when (this) { is ExpiryMode.AfterRead -> SignalServiceProtos.Content.ExpirationType.DELETE_AFTER_READ_VALUE is ExpiryMode.AfterSend -> SignalServiceProtos.Content.ExpirationType.DELETE_AFTER_SEND_VALUE + is ExpiryMode.Legacy -> SignalServiceProtos.Content.ExpirationType.UNKNOWN_VALUE else -> -1 } } @@ -16,7 +17,7 @@ fun SignalServiceProtos.Content.ExpirationType?.expiryMode(durationSeconds: Long null -> null SignalServiceProtos.Content.ExpirationType.DELETE_AFTER_READ -> ExpiryMode.AfterRead(durationSeconds) SignalServiceProtos.Content.ExpirationType.DELETE_AFTER_SEND -> ExpiryMode.AfterSend(durationSeconds) - SignalServiceProtos.Content.ExpirationType.UNKNOWN -> null + SignalServiceProtos.Content.ExpirationType.UNKNOWN -> ExpiryMode.Legacy(durationSeconds) } fun Int.expiryType(): KClass? { @@ -24,6 +25,7 @@ fun Int.expiryType(): KClass? { return when (this) { SignalServiceProtos.Content.ExpirationType.DELETE_AFTER_READ_VALUE -> ExpiryMode.AfterSend::class SignalServiceProtos.Content.ExpirationType.DELETE_AFTER_SEND_VALUE -> ExpiryMode.AfterRead::class + SignalServiceProtos.Content.ExpirationType.UNKNOWN_VALUE -> ExpiryMode.Legacy::class else -> ExpiryMode.NONE::class } } \ No newline at end of file