0
0
mirror of https://github.com/thunderbird/thunderbird-android.git synced 2024-09-20 04:02:14 +02:00

Merge pull request #7119 from thundernest/fix_toAccountOptionsState

Fix `AccountSetupState.toAccountOptionsState()`
This commit is contained in:
cketti 2023-08-14 12:30:47 +02:00 committed by GitHub
commit 6afee20873
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View File

@ -20,6 +20,10 @@ enum class EmailCheckFrequency(
companion object {
val DEFAULT = EVERY_HOUR
fun all() = values().toList().toImmutableList()
fun fromMinutes(minutes: Int): EmailCheckFrequency {
return all().find { it.minutes == minutes } ?: DEFAULT
}
}
}

View File

@ -18,5 +18,9 @@ enum class EmailDisplayCount(
companion object {
val DEFAULT = MESSAGES_25
fun all() = values().toList().toImmutableList()
fun fromCount(count: Int): EmailDisplayCount {
return all().find { it.count == count } ?: DEFAULT
}
}
}

View File

@ -18,8 +18,8 @@ internal fun AccountSetupState.toAccountOptionsState(): State {
accountName = StringInputField(options.accountName),
displayName = StringInputField(options.displayName),
emailSignature = StringInputField(options.emailSignature ?: ""),
checkFrequency = EmailCheckFrequency.valueOf(options.checkFrequencyInMinutes.toString()),
messageDisplayCount = EmailDisplayCount.valueOf(options.messageDisplayCount.toString()),
checkFrequency = EmailCheckFrequency.fromMinutes(options.checkFrequencyInMinutes),
messageDisplayCount = EmailDisplayCount.fromCount(options.messageDisplayCount),
showNotification = options.showNotification,
)
}