mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-09 12:53:38 +00:00
Show correct options for note to self
This commit is contained in:
parent
cc5cd51ac1
commit
6602f1bd14
@ -46,7 +46,7 @@ class ExpirationSettingsViewModel(
|
|||||||
val uiState = _state.map {
|
val uiState = _state.map {
|
||||||
UiState(
|
UiState(
|
||||||
cards = listOf(
|
cards = listOf(
|
||||||
CardModel(GetString(R.string.activity_expiration_settings_delete_type), typeOptions(it.expiryType)),
|
CardModel(GetString(R.string.activity_expiration_settings_delete_type), typeOptions(it)),
|
||||||
CardModel(GetString(R.string.activity_expiration_settings_timer), timeOptions(it))
|
CardModel(GetString(R.string.activity_expiration_settings_timer), timeOptions(it))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -69,8 +69,6 @@ class ExpirationSettingsViewModel(
|
|||||||
expiryMode = expiryMode
|
expiryMode = expiryMode
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// selectedExpirationType.mapLatest {
|
// selectedExpirationType.mapLatest {
|
||||||
// when (it) {
|
// when (it) {
|
||||||
@ -86,7 +84,7 @@ class ExpirationSettingsViewModel(
|
|||||||
// }.launchIn(viewModelScope)
|
// }.launchIn(viewModelScope)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun typeOption(
|
private fun typeOption(
|
||||||
type: ExpiryType,
|
type: ExpiryType,
|
||||||
selected: ExpiryType?,
|
selected: ExpiryType?,
|
||||||
@StringRes title: Int,
|
@StringRes title: Int,
|
||||||
@ -94,11 +92,13 @@ class ExpirationSettingsViewModel(
|
|||||||
@StringRes contentDescription: Int = title
|
@StringRes contentDescription: Int = title
|
||||||
) = OptionModel(GetString(title), subtitle?.let(::GetString), selected = selected == type) { setType(type) }
|
) = OptionModel(GetString(title), subtitle?.let(::GetString), selected = selected == type) { setType(type) }
|
||||||
|
|
||||||
private fun typeOptions(selected: ExpiryType?) = listOf(
|
private fun typeOptions(state: State) =
|
||||||
typeOption(ExpiryType.NONE, selected, R.string.expiration_off, contentDescription = R.string.AccessibilityId_disable_disappearing_messages),
|
if (state.isSelf) emptyList()
|
||||||
typeOption(ExpiryType.LEGACY, selected, R.string.expiration_type_disappear_legacy, contentDescription = R.string.expiration_type_disappear_legacy_description),
|
else listOf(
|
||||||
typeOption(ExpiryType.AFTER_READ, selected, R.string.expiration_type_disappear_after_read, contentDescription = R.string.expiration_type_disappear_after_read_description),
|
typeOption(ExpiryType.NONE, state.expiryType, R.string.expiration_off, contentDescription = R.string.AccessibilityId_disable_disappearing_messages),
|
||||||
typeOption(ExpiryType.AFTER_SEND, selected, R.string.expiration_type_disappear_after_send, contentDescription = R.string.expiration_type_disappear_after_send_description),
|
typeOption(ExpiryType.LEGACY, state.expiryType, R.string.expiration_type_disappear_legacy, contentDescription = R.string.expiration_type_disappear_legacy_description),
|
||||||
|
typeOption(ExpiryType.AFTER_READ, state.expiryType, R.string.expiration_type_disappear_after_read, contentDescription = R.string.expiration_type_disappear_after_read_description),
|
||||||
|
typeOption(ExpiryType.AFTER_SEND, state.expiryType, R.string.expiration_type_disappear_after_send, contentDescription = R.string.expiration_type_disappear_after_send_description),
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun setType(type: ExpiryType) {
|
private fun setType(type: ExpiryType) {
|
||||||
@ -121,7 +121,8 @@ class ExpirationSettingsViewModel(
|
|||||||
fun timeOption(seconds: Long, title: String, subtitle: String) = OptionModel(GetString(title), GetString(subtitle), selected = false, onClick = { setTime(seconds) })
|
fun timeOption(seconds: Long, title: String, subtitle: String) = OptionModel(GetString(title), GetString(subtitle), selected = false, onClick = { setTime(seconds) })
|
||||||
|
|
||||||
// private fun timeOptions(state: State) = timeOptions(state.types.isEmpty(), state.expiryType == ExpiryType.AFTER_SEND)
|
// private fun timeOptions(state: State) = timeOptions(state.types.isEmpty(), state.expiryType == ExpiryType.AFTER_SEND)
|
||||||
private fun timeOptions(state: State): List<OptionModel> = if (state.isSelf) noteToSelfOptions(state.expiryType)
|
private fun timeOptions(state: State): List<OptionModel> =
|
||||||
|
if (state.isSelf) noteToSelfOptions(state.expiryType)
|
||||||
else when (state.expiryMode) {
|
else when (state.expiryMode) {
|
||||||
is ExpiryMode.Legacy -> afterReadTimes
|
is ExpiryMode.Legacy -> afterReadTimes
|
||||||
is ExpiryMode.AfterRead -> afterReadTimes
|
is ExpiryMode.AfterRead -> afterReadTimes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user