Add AccountOptions and state mapper
This commit is contained in:
parent
5384350689
commit
1c142876d0
5 changed files with 63 additions and 2 deletions
|
@ -18,11 +18,11 @@ class AccountCreator(
|
|||
val newAccount = preferences.newAccount()
|
||||
|
||||
newAccount.email = account.emailAddress
|
||||
newAccount.senderName = account.senderName
|
||||
|
||||
newAccount.incomingServerSettings = account.incomingServerSettings
|
||||
newAccount.outgoingServerSettings = account.outgoingServerSettings
|
||||
|
||||
newAccount.senderName = account.options.accountName
|
||||
newAccount.deletePolicy = accountCreatorHelper.getDefaultDeletePolicy(newAccount.incomingServerSettings.type)
|
||||
newAccount.chipColor = accountCreatorHelper.pickColor()
|
||||
|
||||
|
|
|
@ -6,5 +6,5 @@ data class Account(
|
|||
val emailAddress: String,
|
||||
val incomingServerSettings: ServerSettings,
|
||||
val outgoingServerSettings: ServerSettings,
|
||||
val senderName: String,
|
||||
val options: AccountOptions,
|
||||
)
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package app.k9mail.feature.account.setup.domain.entity
|
||||
|
||||
data class AccountOptions(
|
||||
val accountName: String,
|
||||
val displayName: String,
|
||||
val emailSignature: String?,
|
||||
val checkFrequencyInMinutes: Int,
|
||||
val messageDisplayCount: Int,
|
||||
val showNotification: Boolean,
|
||||
)
|
|
@ -0,0 +1,14 @@
|
|||
package app.k9mail.feature.account.setup.ui.options
|
||||
|
||||
import app.k9mail.feature.account.setup.domain.entity.AccountOptions
|
||||
|
||||
internal fun AccountOptionsContract.State.toAccountOptions(): AccountOptions {
|
||||
return AccountOptions(
|
||||
accountName = accountName.value,
|
||||
displayName = displayName.value,
|
||||
emailSignature = emailSignature.value,
|
||||
checkFrequencyInMinutes = checkFrequency.minutes,
|
||||
messageDisplayCount = messageDisplayCount.count,
|
||||
showNotification = showNotification,
|
||||
)
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package app.k9mail.feature.account.setup.ui.options
|
||||
|
||||
import app.k9mail.feature.account.setup.domain.entity.AccountOptions
|
||||
import app.k9mail.feature.account.setup.domain.entity.EmailCheckFrequency
|
||||
import app.k9mail.feature.account.setup.domain.entity.EmailDisplayCount
|
||||
import app.k9mail.feature.account.setup.domain.input.StringInputField
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.isEqualTo
|
||||
import org.junit.Test
|
||||
|
||||
class AccountOptionsStateMapperKtTest {
|
||||
|
||||
@Test
|
||||
fun `should map state to account options`() {
|
||||
val state = AccountOptionsContract.State(
|
||||
accountName = StringInputField("accountName"),
|
||||
displayName = StringInputField("displayName"),
|
||||
emailSignature = StringInputField("emailSignature"),
|
||||
checkFrequency = EmailCheckFrequency.EVERY_2_HOURS,
|
||||
messageDisplayCount = EmailDisplayCount.MESSAGES_100,
|
||||
showNotification = true,
|
||||
)
|
||||
|
||||
val result = state.toAccountOptions()
|
||||
|
||||
assertThat(result).isEqualTo(
|
||||
AccountOptions(
|
||||
accountName = "accountName",
|
||||
displayName = "displayName",
|
||||
emailSignature = "emailSignature",
|
||||
checkFrequencyInMinutes = 120,
|
||||
messageDisplayCount = 100,
|
||||
showNotification = true,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue