diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/Components.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/Components.kt index 19d82bddc0..8f4cd14f02 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/Components.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/Components.kt @@ -49,6 +49,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.compose.ui.viewinterop.AndroidView import org.session.libsession.utilities.recipients.Recipient +import org.session.libsession.utilities.runIf import org.thoughtcrime.securesms.components.ProfilePictureView import org.thoughtcrime.securesms.conversation.disappearingmessages.ui.OptionsCard import kotlin.math.min @@ -150,7 +151,7 @@ fun TitledRadioButton(option: RadioOption, onClick: () -> Unit) { Row( horizontalArrangement = Arrangement.spacedBy(16.dp), modifier = Modifier - .clickable { if (!option.selected) onClick() } + .runIf(option.enabled) { clickable { if (!option.selected) onClick() } } .heightIn(min = 60.dp) .padding(horizontal = 32.dp) .contentDescription(option.contentDescription) diff --git a/libsession/src/main/java/org/session/libsession/utilities/Util.kt b/libsession/src/main/java/org/session/libsession/utilities/Util.kt index 540f8e0975..17009caa7d 100644 --- a/libsession/src/main/java/org/session/libsession/utilities/Util.kt +++ b/libsession/src/main/java/org/session/libsession/utilities/Util.kt @@ -367,6 +367,8 @@ object Util { } } +fun T.runIf(condition: Boolean, block: T.() -> R): R where T: R = if (condition) block() else this + fun Iterable.associateByNotNull( keySelector: (T) -> K? ) = associateByNotNull(keySelector) { it }