Fix nts options and add 10 second debug time

This commit is contained in:
andrew 2023-09-07 13:48:16 +09:30
parent 96afa8d23f
commit 0c9d050ef6

View File

@ -41,6 +41,7 @@ import kotlin.time.Duration
import kotlin.time.Duration.Companion.days import kotlin.time.Duration.Companion.days
import kotlin.time.Duration.Companion.hours import kotlin.time.Duration.Companion.hours
import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.seconds
enum class Event { enum class Event {
SUCCESS, FAIL SUCCESS, FAIL
@ -112,6 +113,7 @@ class ExpirationSettingsViewModel(
state.copy( state.copy(
address = recipient?.address, address = recipient?.address,
isGroup = groupInfo != null, isGroup = groupInfo != null,
isNoteToSelf = recipient?.address?.serialize() == textSecurePreferences.getLocalNumber(),
isSelfAdmin = groupInfo == null || groupInfo.admins.any{ it.serialize() == textSecurePreferences.getLocalNumber() }, isSelfAdmin = groupInfo == null || groupInfo.admins.any{ it.serialize() == textSecurePreferences.getLocalNumber() },
expiryMode = expiryMode expiryMode = expiryMode
) )
@ -288,17 +290,17 @@ private fun timeOptions(state: State) =
else -> null else -> null
}?.map { timeOption(it, state) } }?.map { timeOption(it, state) }
private val DEBUG_TIME = 1.minutes private val DEBUG_TIMES = if (BuildConfig.DEBUG) listOf(10.seconds, 1.minutes) else emptyList()
val defaultTimes = listOf(12.hours, 1.days, 7.days, 14.days) val defaultTimes = listOf(12.hours, 1.days, 7.days, 14.days)
val afterSendTimes = buildList { val afterSendTimes = buildList {
if (BuildConfig.DEBUG) add(DEBUG_TIME) addAll(DEBUG_TIMES)
addAll(defaultTimes) addAll(defaultTimes)
} }
val afterReadTimes = buildList { val afterReadTimes = buildList {
if (BuildConfig.DEBUG) add(DEBUG_TIME) addAll(DEBUG_TIMES)
add(5.minutes) add(5.minutes)
add(1.hours) add(1.hours)
addAll(defaultTimes) addAll(defaultTimes)
@ -318,7 +320,7 @@ 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? = if (duration == DEBUG_TIME) GetString("for testing purposes") else null, subtitle: GetString? = if (duration in DEBUG_TIMES) GetString("for testing purposes") else null,
onClick: () -> Unit = { state.callbacks.setTime(duration.inWholeSeconds) } onClick: () -> Unit = { state.callbacks.setTime(duration.inWholeSeconds) }
) = OptionModel( ) = OptionModel(
title = title, title = title,