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

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

Add default folder selection

parent 29d798b6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ internal fun DrawerContentPreview() {
        DrawerContent(
            state = DrawerContract.State(
                accounts = persistentListOf(),
                currentAccount = null,
                selectedAccount = null,
                folders = persistentListOf(),
            ),
            onEvent = {},
@@ -28,7 +28,7 @@ fun DrawerContentWithAccountPreview() {
        DrawerContent(
            state = DrawerContract.State(
                accounts = persistentListOf(DISPLAY_ACCOUNT),
                currentAccount = DISPLAY_ACCOUNT,
                selectedAccount = DISPLAY_ACCOUNT,
                folders = persistentListOf(),
            ),
            onEvent = {},
+3 −2
Original line number Diff line number Diff line
@@ -3,9 +3,9 @@ package app.k9mail.feature.navigation.drawer.ui
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
import app.k9mail.feature.navigation.drawer.domain.entity.DisplayAccountFolder
import app.k9mail.legacy.account.Account
import app.k9mail.legacy.account.Identity
import app.k9mail.legacy.ui.folder.DisplayFolder

internal object FakeData {

@@ -45,7 +45,8 @@ internal object FakeData {
        isLocalOnly = false,
    )

    val DISPLAY_FOLDER = DisplayFolder(
    val DISPLAY_FOLDER = DisplayAccountFolder(
        accountUuid = ACCOUNT_UUID,
        folder = FOLDER,
        isInTopGroup = false,
        unreadMessageCount = 14,
+2 −2
Original line number Diff line number Diff line
package app.k9mail.feature.navigation.drawer.domain

import app.k9mail.feature.navigation.drawer.domain.entity.DisplayAccount
import app.k9mail.feature.navigation.drawer.domain.entity.DisplayAccountFolder
import app.k9mail.feature.navigation.drawer.domain.entity.DrawerConfig
import app.k9mail.legacy.account.Account
import app.k9mail.legacy.ui.folder.DisplayFolder
import kotlinx.coroutines.flow.Flow

interface DomainContract {
@@ -18,7 +18,7 @@ interface DomainContract {
        }

        fun interface GetDisplayFoldersForAccount {
            operator fun invoke(accountUuid: String): Flow<List<DisplayFolder>>
            operator fun invoke(accountUuid: String): Flow<List<DisplayAccountFolder>>
        }

        /**
+11 −0
Original line number Diff line number Diff line
package app.k9mail.feature.navigation.drawer.domain.entity

import app.k9mail.core.mail.folder.api.Folder

data class DisplayAccountFolder(
    val accountUuid: String,
    val folder: Folder,
    val isInTopGroup: Boolean,
    val unreadMessageCount: Int,
    val starredMessageCount: Int,
)
+14 −3
Original line number Diff line number Diff line
package app.k9mail.feature.navigation.drawer.domain.usecase

import app.k9mail.feature.navigation.drawer.domain.DomainContract.UseCase
import app.k9mail.legacy.ui.folder.DisplayFolder
import app.k9mail.feature.navigation.drawer.domain.entity.DisplayAccountFolder
import app.k9mail.legacy.ui.folder.DisplayFolderRepository
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map

class GetDisplayFoldersForAccount(
    private val repository: DisplayFolderRepository,
) : UseCase.GetDisplayFoldersForAccount {
    override fun invoke(accountUuid: String): Flow<List<DisplayFolder>> {
        return repository.getDisplayFoldersFlow(accountUuid)
    override fun invoke(accountUuid: String): Flow<List<DisplayAccountFolder>> {
        return repository.getDisplayFoldersFlow(accountUuid).map { displayFolders ->
            displayFolders.map { displayFolder ->
                DisplayAccountFolder(
                    accountUuid = accountUuid,
                    folder = displayFolder.folder,
                    isInTopGroup = displayFolder.isInTopGroup,
                    unreadMessageCount = displayFolder.unreadMessageCount,
                    starredMessageCount = displayFolder.starredMessageCount,
                )
            }
        }
    }
}
Loading