Skip to content

Commit

Permalink
Merge pull request #7063 from thundernest/send_client_id
Browse files Browse the repository at this point in the history
Add "Send client ID" to incoming server settings (IMAP)
  • Loading branch information
cketti authored Jul 13, 2023
2 parents b0e05ca + cb78d34 commit bb84da1
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,15 @@ internal fun AccountIncomingConfigContent(
contentPadding = defaultItemPadding(),
)
}

item {
CheckboxInput(
text = stringResource(R.string.account_setup_incoming_config_imap_send_client_id_label),
checked = state.imapSendClientId,
onCheckedChange = { onEvent(Event.ImapSendClientIdChanged(it)) },
contentPadding = defaultItemPadding(),
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface AccountIncomingConfigContract {
val imapAutodetectNamespaceEnabled: Boolean = true,
val imapPrefix: StringInputField = StringInputField(),
val imapUseCompression: Boolean = true,
val imapSendClientId: Boolean = true,

val isSuccess: Boolean = false,
val error: Error? = null,
Expand All @@ -49,6 +50,7 @@ interface AccountIncomingConfigContract {
data class ImapAutoDetectNamespaceChanged(val enabled: Boolean) : Event()
data class ImapPrefixChanged(val imapPrefix: String) : Event()
data class ImapUseCompressionChanged(val useCompression: Boolean) : Event()
data class ImapSendClientIdChanged(val sendClientId: Boolean) : Event()

object OnNextClicked : Event()
object OnBackClicked : Event()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ internal class AccountIncomingConfigViewModel(
}

is Event.ImapUseCompressionChanged -> updateState { it.copy(imapUseCompression = event.useCompression) }
is Event.ImapSendClientIdChanged -> updateState { it.copy(imapSendClientId = event.sendClientId) }

Event.OnNextClicked -> onNext()
Event.OnBackClicked -> onBack()
Expand Down
1 change: 1 addition & 0 deletions feature/account/setup/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<string name="account_setup_incoming_config_imap_namespace_label">Auto-detect IMAP namespace</string>
<string name="account_setup_incoming_config_imap_prefix_label">IMAP path prefix</string>
<string name="account_setup_incoming_config_imap_compression_label">Use compression</string>
<string name="account_setup_incoming_config_imap_send_client_id_label">Send client ID</string>
<string name="account_setup_incoming_config_loading_message">Checking incoming server settings…</string>
<string name="account_setup_incoming_config_loading_error">Checking incoming server settings failed!</string>
<string name="account_setup_incoming_config_success">Incoming server settings are valid!</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class AccountIncomingConfigStateMapperKtTest {
imapAutodetectNamespaceEnabled = true,
imapPrefix = StringInputField(value = "prefix"),
imapUseCompression = true,
imapSendClientId = true,
)

val result = incomingState.toServerSettings()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class AccountIncomingConfigStateTest {
clientCertificate = "",
imapAutodetectNamespaceEnabled = true,
imapUseCompression = true,
imapSendClientId = true,
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,17 @@ class AccountIncomingConfigViewModelTest {
)
}

@Test
fun `should change state when ImapSendClientIdChanged event is received`() = runTest {
eventStateTest(
viewModel = testSubject,
initialState = State(imapSendClientId = true),
event = Event.ImapSendClientIdChanged(false),
expectedState = State(imapSendClientId = false),
coroutineScope = backgroundScope,
)
}

@Test
fun `should emit effect NavigateNext when OnNextClicked is received in success state`() = runTest {
val initialState = State(isSuccess = true)
Expand Down

0 comments on commit bb84da1

Please sign in to comment.