Fix null values in advanced settings

This commit is contained in:
Rafał Kobyłko 2023-10-21 20:55:35 +02:00
parent efe4dc8bd2
commit 3d6d376840
2 changed files with 8 additions and 5 deletions

View File

@ -58,6 +58,10 @@ data class Service(
}
companion object {
val DefaultAlgorithm = Algorithm.SHA1
const val DefaultPeriod = 30
const val DefaultDigits = 6
val Empty = Service(
id = 0L,
serviceTypeId = null,

View File

@ -15,9 +15,8 @@ import com.twofasapp.designsystem.TwTheme
import com.twofasapp.designsystem.common.TwTopAppBar
import com.twofasapp.designsystem.settings.SettingsDivider
import com.twofasapp.designsystem.settings.SettingsLink
import com.twofasapp.locale.TwLocale
import com.twofasapp.locale.R
import com.twofasapp.feature.home.ui.editservice.EditServiceViewModel
import com.twofasapp.locale.TwLocale
@Composable
internal fun AdvancedSettingsScreen(
@ -74,7 +73,7 @@ internal fun AdvancedSettingsScreen(
item {
SettingsLink(
title = TwLocale.strings.addManualAlgorithm,
subtitle = service.algorithm?.name.orEmpty(),
subtitle = service.algorithm?.name ?: Service.DefaultAlgorithm.name,
enabled = false,
)
}
@ -83,7 +82,7 @@ internal fun AdvancedSettingsScreen(
item {
SettingsLink(
title = TwLocale.strings.addManualRefreshTime,
subtitle = service.period.toString(),
subtitle = (service.period ?: Service.DefaultPeriod).toString(),
enabled = false,
)
}
@ -102,7 +101,7 @@ internal fun AdvancedSettingsScreen(
item {
SettingsLink(
title = TwLocale.strings.addManualDigits,
subtitle = service.digits.toString(),
subtitle = (service.digits ?: Service.DefaultDigits).toString(),
enabled = false,
)
}