mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 00:37:47 +00:00
refactor: moving radio indexes out of expiration configuration
This commit is contained in:
parent
0e30d14b96
commit
87d76b21da
@ -71,7 +71,7 @@ class ExpirationSettingsViewModel(
|
||||
if (recipient?.isLocalNumber == true || recipient?.isClosedGroupRecipient == true) {
|
||||
ExpirationType.DELETE_AFTER_SEND.number
|
||||
} else {
|
||||
expirationConfig?.expirationTypeValue ?: -1
|
||||
expirationConfig?.typeRadioIndex() ?: -1
|
||||
}
|
||||
} else {
|
||||
expirationConfig?.expirationTypeValue?.let { 0 /* Legacy */ } ?: -1
|
||||
@ -111,10 +111,10 @@ class ExpirationSettingsViewModel(
|
||||
if (typeValue == 0) {
|
||||
typeValue = ExpirationType.DELETE_AFTER_READ_VALUE
|
||||
}
|
||||
val expiryType = typeValue
|
||||
val expiryType = typeValue.expiry()
|
||||
val expirationTimer = _selectedExpirationTimer.value?.value?.toIntOrNull() ?: 0
|
||||
val address = recipient.value?.address
|
||||
if (address == null || (expirationConfig?.expirationTypeValue == expiryType && expirationConfig?.durationSeconds == expirationTimer)) {
|
||||
if (address == null || (expirationConfig?.typeRadioIndex() == typeValue && expirationConfig?.durationSeconds == expirationTimer)) {
|
||||
_uiState.update {
|
||||
it.copy(settingsSaved = false)
|
||||
}
|
||||
@ -177,3 +177,18 @@ data class ExpirationSettingsUiState(
|
||||
val showExpirationTypeSelector: Boolean = false,
|
||||
val settingsSaved: Boolean? = null
|
||||
)
|
||||
|
||||
fun ExpirationConfiguration?.typeRadioIndex(): Int {
|
||||
if (this == null || expirationType == null) return -1
|
||||
return when {
|
||||
expirationType == ExpirationType.DELETE_AFTER_READ -> ExpirationType.DELETE_AFTER_READ_VALUE
|
||||
else -> -1
|
||||
}
|
||||
|
||||
return if (expirationType == )
|
||||
}
|
||||
|
||||
fun Int.expiry(): ExpirationType? {
|
||||
if (this == -1) return null
|
||||
TODO()
|
||||
}
|
@ -1675,6 +1675,8 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
||||
return if (recipient.isContactRecipient && recipient.address.serialize().startsWith(IdPrefix.STANDARD.value)) {
|
||||
// read it from contacts config if exists
|
||||
configFactory.contacts?.get(recipient.address.serialize())?.let { contact ->
|
||||
val mode = contact.expiryMode
|
||||
ExpirationConfiguration(threadId, mode.expirySeconds,)
|
||||
contact.expiryMode
|
||||
}
|
||||
} else if (recipient.isClosedGroupRecipient) {
|
||||
|
@ -5,10 +5,9 @@ import org.session.libsignal.protos.SignalServiceProtos.Content.ExpirationType
|
||||
class ExpirationConfiguration(
|
||||
val threadId: Long = -1,
|
||||
val durationSeconds: Int = 0,
|
||||
val expirationTypeValue: Int = -1,
|
||||
val expirationType: ExpirationType? = null,
|
||||
val updatedTimestampMs: Long = 0
|
||||
) {
|
||||
val expirationType: ExpirationType? = ExpirationType.valueOf(expirationTypeValue)
|
||||
val isEnabled = durationSeconds > 0 && expirationType != null
|
||||
|
||||
companion object {
|
||||
|
Loading…
x
Reference in New Issue
Block a user