Update the Send max access count logic (#557)

This commit is contained in:
David Perez
2024-01-09 20:35:05 -06:00
committed by Álison Fernandes
parent 27ddac59b9
commit 49411f3e2f
4 changed files with 24 additions and 26 deletions

View File

@@ -228,6 +228,7 @@ private fun AddSendOptions(
value = state.common.maxAccessCount,
onValueChange = addSendHandlers.onMaxAccessCountChange,
isDecrementEnabled = state.common.maxAccessCount != null,
range = 0..Int.MAX_VALUE,
modifier = Modifier
.padding(horizontal = 16.dp),
)

View File

@@ -261,7 +261,9 @@ class AddSendViewModel @Inject constructor(
}
private fun handleMaxAccessCountChange(action: AddSendAction.MaxAccessCountChange) {
updateCommonContent { it.copy(maxAccessCount = action.value) }
updateCommonContent { common ->
common.copy(maxAccessCount = action.value.takeUnless { it == 0 })
}
}
private inline fun onContent(
@@ -355,7 +357,6 @@ data class AddSendState(
@Parcelize
data class Common(
val name: String,
// Null here means "not set"
val maxAccessCount: Int?,
val passwordInput: String,
val noteInput: String,