mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 20:15:21 +00:00
Utilise typealias for RadioOptions
This commit is contained in:
parent
60f396a158
commit
9123dd90a4
@ -29,8 +29,8 @@ import kotlin.reflect.KClass
|
||||
|
||||
class ExpirationSettingsViewModel(
|
||||
private val threadId: Long,
|
||||
private val afterReadOptions: List<RadioOption<ExpiryMode>>,
|
||||
private val afterSendOptions: List<RadioOption<ExpiryMode>>,
|
||||
private val afterReadOptions: List<ExpirationRadioOption>,
|
||||
private val afterSendOptions: List<ExpirationRadioOption>,
|
||||
private val textSecurePreferences: TextSecurePreferences,
|
||||
private val messageExpirationManager: MessageExpirationManagerProtocol,
|
||||
private val threadDb: ThreadDatabase,
|
||||
@ -93,11 +93,11 @@ class ExpirationSettingsViewModel(
|
||||
}.onEach { options ->
|
||||
val enabled = _uiState.value.isSelfAdmin || recipient.value?.isClosedGroupRecipient == true
|
||||
_expirationTimerOptions.value = if (ExpirationConfiguration.isNewConfigEnabled && (recipient.value?.isLocalNumber == true || recipient.value?.isClosedGroupRecipient == true)) {
|
||||
options.filterIsInstance<ExpirationRadioOption>().map {
|
||||
options.map {
|
||||
it.copy(enabled = enabled)
|
||||
}
|
||||
} else {
|
||||
options.slice(1 until options.size).filterIsInstance<ExpirationRadioOption>().map {
|
||||
options.slice(1 until options.size).map {
|
||||
it.copy(enabled = enabled)
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ class RadioOptionAdapter<T>(
|
||||
|
||||
}
|
||||
|
||||
sealed class RadioOption<T>(
|
||||
data class RadioOption<T>(
|
||||
val value: T,
|
||||
val title: String,
|
||||
val subtitle: String? = null,
|
||||
@ -76,35 +76,5 @@ sealed class RadioOption<T>(
|
||||
val contentDescription: String = ""
|
||||
)
|
||||
|
||||
class StringRadioOption(value: String,
|
||||
title: String,
|
||||
subtitle: String? = null,
|
||||
enabled: Boolean = true,
|
||||
contentDescription: String = ""): RadioOption<String>(
|
||||
value,
|
||||
title,
|
||||
subtitle,
|
||||
enabled,
|
||||
contentDescription
|
||||
)
|
||||
|
||||
class ExpirationRadioOption(
|
||||
value: ExpiryMode,
|
||||
title: String,
|
||||
subtitle: String? = null,
|
||||
enabled: Boolean = true,
|
||||
contentDescription: String = ""
|
||||
): RadioOption<ExpiryMode>(
|
||||
value,
|
||||
title,
|
||||
subtitle,
|
||||
enabled,
|
||||
contentDescription
|
||||
) {
|
||||
fun copy(value: ExpiryMode = this.value,
|
||||
title: String = this.title,
|
||||
subtitle: String? = this.subtitle,
|
||||
enabled: Boolean = this.enabled,
|
||||
contentDescription: String = this.contentDescription) =
|
||||
ExpirationRadioOption(value, title, subtitle, enabled, contentDescription)
|
||||
}
|
||||
typealias StringRadioOption = RadioOption<String>
|
||||
typealias ExpirationRadioOption = RadioOption<ExpiryMode>
|
||||
|
Loading…
Reference in New Issue
Block a user