Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit dd842775 authored by Wolf-Martell Montwé's avatar Wolf-Martell Montwé
Browse files

Fix drawer not updating on account changes

parent 2177b2a9
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ internal fun DrawerContentWithAccountPreview() {
        DrawerContent(
            state = DrawerContract.State(
                accounts = persistentListOf(DISPLAY_ACCOUNT),
                selectedAccountId = DISPLAY_ACCOUNT.uuid,
                selectedAccountId = DISPLAY_ACCOUNT.id,
                folders = persistentListOf(),
            ),
            onEvent = {},
@@ -67,7 +67,7 @@ internal fun DrawerContentWithSelectedFolderPreview() {
                accounts = persistentListOf(
                    DISPLAY_ACCOUNT,
                ),
                selectedAccountId = DISPLAY_ACCOUNT.uuid,
                selectedAccountId = DISPLAY_ACCOUNT.id,
                folders = persistentListOf(
                    UNIFIED_FOLDER,
                    DISPLAY_FOLDER,
@@ -88,7 +88,7 @@ internal fun DrawerContentWithSelectedUnifiedFolderPreview() {
                accounts = persistentListOf(
                    DISPLAY_ACCOUNT,
                ),
                selectedAccountId = DISPLAY_ACCOUNT.uuid,
                selectedAccountId = DISPLAY_ACCOUNT.id,
                folders = persistentListOf(
                    UNIFIED_FOLDER,
                    DISPLAY_FOLDER,
+6 −1
Original line number Diff line number Diff line
package app.k9mail.feature.navigation.drawer.ui

import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import app.k9mail.core.mail.folder.api.Folder
import app.k9mail.core.mail.folder.api.FolderType
import app.k9mail.feature.navigation.drawer.domain.entity.DisplayAccount
@@ -35,7 +37,10 @@ internal object FakeData {
    }

    val DISPLAY_ACCOUNT = DisplayAccount(
        account = ACCOUNT,
        id = ACCOUNT_UUID,
        name = DISPLAY_NAME,
        email = EMAIL_ADDRESS,
        color = Color.Red.toArgb(),
        unreadMessageCount = 0,
        starredMessageCount = 0,
    )
+5 −6
Original line number Diff line number Diff line
package app.k9mail.feature.navigation.drawer.domain.entity

import app.k9mail.legacy.account.Account

internal data class DisplayAccount(
    val account: Account,
    val id: String,
    val name: String,
    val email: String,
    val color: Int,
    val unreadMessageCount: Int,
    val starredMessageCount: Int,
) {
    val uuid: String = account.uuid
}
)
+4 −1
Original line number Diff line number Diff line
@@ -37,7 +37,10 @@ internal class GetDisplayAccounts(
                combine(messageCountsFlows) { messageCountsList ->
                    messageCountsList.mapIndexed { index, messageCounts ->
                        DisplayAccount(
                            account = accounts[index],
                            id = accounts[index].uuid,
                            name = accounts[index].displayName,
                            email = accounts[index].email,
                            color = accounts[index].chipColor,
                            unreadMessageCount = messageCounts.unread,
                            starredMessageCount = messageCounts.starred,
                        )
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ internal fun DrawerContent(
            .fillMaxHeight()
            .testTag("DrawerContent"),
    ) {
        val selectedAccount = state.accounts.firstOrNull { it.uuid == state.selectedAccountId }
        val selectedAccount = state.accounts.firstOrNull { it.id == state.selectedAccountId }
        Column {
            selectedAccount?.let {
                AccountView(
Loading