mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +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 {
|
init {
|
||||||
// SETUP
|
// SETUP
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
expirationConfig = storage.getExpirationConfiguration(threadId)
|
expirationConfig = storage.getExpirationConfiguration(threadId)?.let {
|
||||||
|
if (ExpirationConfiguration.isNewConfigEnabled) it
|
||||||
|
else if (it)
|
||||||
|
}
|
||||||
val expirationType = expirationConfig?.expiryMode
|
val expirationType = expirationConfig?.expiryMode
|
||||||
val recipient = threadDb.getRecipientForThreadId(threadId)
|
val recipient = threadDb.getRecipientForThreadId(threadId)
|
||||||
_recipient.value = recipient
|
_recipient.value = recipient
|
||||||
@ -121,8 +124,12 @@ class ExpirationSettingsViewModel(
|
|||||||
|
|
||||||
fun onSetClick() = viewModelScope.launch {
|
fun onSetClick() = viewModelScope.launch {
|
||||||
val expiryMode = _selectedExpirationTimer.value?.value ?: ExpiryMode.NONE
|
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
|
val address = recipient.value?.address
|
||||||
if (address == null || (expirationConfig?.expiryMode != expiryMode)) {
|
if (address == null || (expirationConfig?.expiryMode == typeValue)) {
|
||||||
_uiState.update {
|
_uiState.update {
|
||||||
it.copy(settingsSaved = false)
|
it.copy(settingsSaved = false)
|
||||||
}
|
}
|
||||||
@ -130,13 +137,13 @@ class ExpirationSettingsViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val expiryChangeTimestampMs = SnodeAPI.nowWithOffset
|
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.sender = textSecurePreferences.getLocalNumber()
|
||||||
message.recipient = address.serialize()
|
message.recipient = address.serialize()
|
||||||
message.sentTimestamp = expiryChangeTimestampMs
|
message.sentTimestamp = expiryChangeTimestampMs
|
||||||
messageExpirationManager.setExpirationTimer(message, expiryMode)
|
messageExpirationManager.setExpirationTimer(message, typeValue)
|
||||||
|
|
||||||
MessageSender.send(message, address)
|
MessageSender.send(message, address)
|
||||||
_uiState.update {
|
_uiState.update {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user