mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-25 20:07:21 +00:00
Fix time option not selecting when type options are off
This commit is contained in:
parent
519bf38ee0
commit
cdb7a5f5d6
@ -290,20 +290,29 @@ val afterReadTimes = listOf(5.minutes, 1.hours) + afterSendTimes
|
|||||||
|
|
||||||
private fun timeOptionsOnly(state: State) = listOfNotNull(
|
private fun timeOptionsOnly(state: State) = listOfNotNull(
|
||||||
typeOption(ExpiryType.NONE, state, R.string.arrays__off, enabled = state.isSelfAdmin),
|
typeOption(ExpiryType.NONE, state, R.string.arrays__off, enabled = state.isSelfAdmin),
|
||||||
timeOption(1.minutes, state, subtitle = GetString("for testing purposes")).takeIf { BuildConfig.DEBUG },
|
if (BuildConfig.DEBUG) timeOptionOnly(1.minutes, state, subtitle = GetString("for testing purposes")) else null,
|
||||||
) + afterSendTimes.map { timeOption(it, state) }
|
) + afterSendTimes.map { timeOptionOnly(it, state) }
|
||||||
|
|
||||||
|
private fun timeOptionOnly(
|
||||||
|
duration: Duration,
|
||||||
|
state: State,
|
||||||
|
title: GetString = GetString { ExpirationUtil.getExpirationDisplayValue(it, duration.inWholeSeconds.toInt()) },
|
||||||
|
subtitle: GetString? = null,
|
||||||
|
) = timeOption(duration, state, title, subtitle) { state.callbacks.setMode(ExpiryMode.AfterSend(duration.inWholeSeconds)) }
|
||||||
|
|
||||||
private fun timeOption(
|
private fun timeOption(
|
||||||
duration: Duration,
|
duration: Duration,
|
||||||
state: State,
|
state: State,
|
||||||
title: GetString = GetString { ExpirationUtil.getExpirationDisplayValue(it, duration.inWholeSeconds.toInt()) },
|
title: GetString = GetString { ExpirationUtil.getExpirationDisplayValue(it, duration.inWholeSeconds.toInt()) },
|
||||||
subtitle: GetString? = null
|
subtitle: GetString? = null,
|
||||||
|
onClick: () -> Unit = { state.callbacks.setTime(duration.inWholeSeconds) }
|
||||||
) = OptionModel(
|
) = OptionModel(
|
||||||
title = title,
|
title = title,
|
||||||
subtitle = subtitle,
|
subtitle = subtitle,
|
||||||
selected = state.expiryMode?.duration == duration,
|
selected = state.expiryMode?.duration == duration,
|
||||||
enabled = state.isTimeOptionsEnabled
|
enabled = state.isTimeOptionsEnabled,
|
||||||
) { state.callbacks.setTime(duration.inWholeSeconds) }
|
onClick = onClick
|
||||||
|
)
|
||||||
|
|
||||||
data class OptionModel(
|
data class OptionModel(
|
||||||
val title: GetString,
|
val title: GetString,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user