mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 00:37:47 +00:00
fix: error with legacy type and set type check
This commit is contained in:
parent
9faa400a5b
commit
d6dd7a82f1
@ -58,7 +58,10 @@ class ExpirationSettingsViewModel(
|
||||
init {
|
||||
// SETUP
|
||||
viewModelScope.launch {
|
||||
expirationConfig = storage.getExpirationConfiguration(threadId)
|
||||
expirationConfig = storage.getExpirationConfiguration(threadId)?.let {
|
||||
if (ExpirationConfiguration.isNewConfigEnabled) it
|
||||
else if (it)
|
||||
}
|
||||
val expirationType = expirationConfig?.expiryMode
|
||||
val recipient = threadDb.getRecipientForThreadId(threadId)
|
||||
_recipient.value = recipient
|
||||
@ -121,8 +124,12 @@ class ExpirationSettingsViewModel(
|
||||
|
||||
fun onSetClick() = viewModelScope.launch {
|
||||
val expiryMode = _selectedExpirationTimer.value?.value ?: ExpiryMode.NONE
|
||||
val typeValue = expiryMode.let {
|
||||
if (it is ExpiryMode.Legacy) ExpiryMode.AfterRead(it.expirySeconds)
|
||||
else it
|
||||
}
|
||||
val address = recipient.value?.address
|
||||
if (address == null || (expirationConfig?.expiryMode != expiryMode)) {
|
||||
if (address == null || (expirationConfig?.expiryMode == typeValue)) {
|
||||
_uiState.update {
|
||||
it.copy(settingsSaved = false)
|
||||
}
|
||||
@ -130,13 +137,13 @@ class ExpirationSettingsViewModel(
|
||||
}
|
||||
|
||||
val expiryChangeTimestampMs = SnodeAPI.nowWithOffset
|
||||
storage.setExpirationConfiguration(ExpirationConfiguration(threadId, expiryMode, expiryChangeTimestampMs))
|
||||
storage.setExpirationConfiguration(ExpirationConfiguration(threadId, typeValue, expiryChangeTimestampMs))
|
||||
|
||||
val message = ExpirationTimerUpdate(expiryMode.expirySeconds.toInt())
|
||||
val message = ExpirationTimerUpdate(typeValue.expirySeconds.toInt())
|
||||
message.sender = textSecurePreferences.getLocalNumber()
|
||||
message.recipient = address.serialize()
|
||||
message.sentTimestamp = expiryChangeTimestampMs
|
||||
messageExpirationManager.setExpirationTimer(message, expiryMode)
|
||||
messageExpirationManager.setExpirationTimer(message, typeValue)
|
||||
|
||||
MessageSender.send(message, address)
|
||||
_uiState.update {
|
||||
|
Loading…
x
Reference in New Issue
Block a user