Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ internal fun AvatarLayout(
shape = CircleShape,
color = color,
)
.clickable(
enabled = onClick != null,
onClick = { onClick?.invoke() },
.then(
if (onClick != null) {
Modifier.clickable(onClick = onClick)
} else {
Modifier
},
),
contentAlignment = Alignment.Center,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,14 @@ internal class DrawerViewModel(
private fun openAccount(account: DisplayAccount?) {
if (account != null) {
emitEffect(Effect.OpenAccount(account.id))
if (account is MailDisplayAccount && account.hasAutoExpandFolder) {
viewModelScope.launch {
delay(DRAWER_CLOSE_DELAY)
viewModelScope.launch {
delay(DRAWER_CLOSE_DELAY)
updateState {
it.copy(
showAccountSelection = false,
)
}
if (account is MailDisplayAccount && account.hasAutoExpandFolder) {
emitEffect(Effect.CloseDrawer)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,35 @@ internal class DrawerViewModelTest {
}
}

@Test
fun `should not emit CloseDrawer effect after emitting OpenAccount if AutoExpandFolder is None`() = runMviTest {
val displayAccounts = createDisplayAccountList(1) + createDisplayAccount(
id = "uuid-1",
hasAutoExpandFolder = false,
)
val getDisplayAccountsFlow = MutableStateFlow(displayAccounts)
val testSubject = createTestSubject(
displayAccountsFlow = getDisplayAccountsFlow,
)
val turbines = turbinesWithInitialStateCheck(
testSubject,
State(
accounts = displayAccounts.toImmutableList(),
selectedAccountId = displayAccounts.first().id,
),
)
advanceUntilIdle()

testSubject.event(Event.OnAccountClick(displayAccounts[1]))

assertThat(turbines.awaitEffectItem()).isEqualTo(
Effect.OpenAccount(displayAccounts[1].id),
)

advanceUntilIdle()
turbines.effectTurbine.expectNoEvents()
}

@Test
fun `should collect display folders for selected account`() = runTest {
val displayAccounts = createDisplayAccountList(3)
Expand Down
Loading