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

Unverified Commit 5938fb89 authored by Wolf-Martell Montwé's avatar Wolf-Martell Montwé Committed by GitHub
Browse files

Merge pull request #8735 from shamim-emon/fix-issue-8709

Fixes New menu forgets its "Hide accounts" setting
parents 4a0a7a46 7c30959d
Loading
Loading
Loading
Loading
+36 −7
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import app.k9mail.core.ui.compose.designsystem.PreviewWithTheme
import app.k9mail.core.ui.compose.designsystem.atom.Surface
import app.k9mail.feature.navigation.drawer.NavigationDrawerExternalContract.DrawerConfig
import app.k9mail.feature.navigation.drawer.ui.FakeData.DISPLAY_ACCOUNT
import app.k9mail.feature.navigation.drawer.ui.FakeData.DISPLAY_FOLDER
import app.k9mail.feature.navigation.drawer.ui.FakeData.UNIFIED_FOLDER
@@ -121,8 +122,12 @@ internal fun DrawerContentSingleAccountPreview() {
                selectedAccountId = DISPLAY_ACCOUNT.id,
                folders = displayFolders,
                selectedFolderId = displayFolders[0].id,
                config = DrawerConfig(
                    showUnifiedFolders = false,
                    showStarredCount = false,
                    showAccountSelector = false,
                ),
            ),
            onEvent = {},
        )
    }
@@ -142,8 +147,12 @@ internal fun DrawerContentSingleAccountWithAccountSelectionPreview() {
                selectedAccountId = DISPLAY_ACCOUNT.id,
                folders = displayFolders,
                selectedFolderId = displayFolders[0].id,
                config = DrawerConfig(
                    showUnifiedFolders = false,
                    showStarredCount = false,
                    showAccountSelector = true,
                ),
            ),
            onEvent = {},
        )
    }
@@ -162,8 +171,12 @@ internal fun DrawerContentMultipleAccountsAccountPreview() {
                selectedAccountId = accountList[0].id,
                folders = displayFolders,
                selectedFolderId = UNIFIED_FOLDER.id,
                config = DrawerConfig(
                    showUnifiedFolders = false,
                    showStarredCount = false,
                    showAccountSelector = false,
                ),
            ),
            onEvent = {},
        )
    }
@@ -181,8 +194,12 @@ internal fun DrawerContentMultipleAccountsWithAccountSelectionPreview() {
                selectedAccountId = accountList[1].id,
                folders = createDisplayFolderList(hasUnifiedFolder = true),
                selectedFolderId = UNIFIED_FOLDER.id,
                config = DrawerConfig(
                    showUnifiedFolders = false,
                    showStarredCount = false,
                    showAccountSelector = true,
                ),
            ),
            onEvent = {},
        )
    }
@@ -200,8 +217,12 @@ internal fun DrawerContentMultipleAccountsWithDifferentAccountSelectionPreview()
                selectedAccountId = accountList[2].id,
                folders = createDisplayFolderList(hasUnifiedFolder = true),
                selectedFolderId = UNIFIED_FOLDER.id,
                config = DrawerConfig(
                    showUnifiedFolders = false,
                    showStarredCount = false,
                    showAccountSelector = true,
                ),
            ),
            onEvent = {},
        )
    }
@@ -224,8 +245,12 @@ internal fun DrawerContentSmallScreenPreview() {
                    selectedAccountId = accountList[2].id,
                    folders = createDisplayFolderList(hasUnifiedFolder = true),
                    selectedFolderId = UNIFIED_FOLDER.id,
                    config = DrawerConfig(
                        showUnifiedFolders = false,
                        showStarredCount = false,
                        showAccountSelector = true,
                    ),
                ),
                onEvent = {},
            )
        }
@@ -249,8 +274,12 @@ internal fun DrawerContentVerySmallScreenPreview() {
                    selectedAccountId = accountList[2].id,
                    folders = createDisplayFolderList(hasUnifiedFolder = true),
                    selectedFolderId = UNIFIED_FOLDER.id,
                    config = DrawerConfig(
                        showUnifiedFolders = false,
                        showStarredCount = false,
                        showAccountSelector = true,
                    ),
                ),
                onEvent = {},
            )
        }
+8 −1
Original line number Diff line number Diff line
package app.k9mail.feature.navigation.drawer

import kotlinx.coroutines.flow.Flow

interface NavigationDrawerExternalContract {

    data class DrawerConfig(
        val showUnifiedFolders: Boolean,
        val showStarredCount: Boolean,
        val showAccountSelector: Boolean,
    )

    fun interface DrawerConfigLoader {
        fun loadDrawerConfig(): DrawerConfig
        fun loadDrawerConfigFlow(): Flow<DrawerConfig>
    }

    fun interface DrawerConfigWriter {
        fun writeDrawerConfig(drawerConfig: DrawerConfig)
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import app.k9mail.feature.navigation.drawer.domain.DomainContract.UseCase
import app.k9mail.feature.navigation.drawer.domain.usecase.GetDisplayAccounts
import app.k9mail.feature.navigation.drawer.domain.usecase.GetDisplayFoldersForAccount
import app.k9mail.feature.navigation.drawer.domain.usecase.GetDrawerConfig
import app.k9mail.feature.navigation.drawer.domain.usecase.SaveDrawerConfig
import app.k9mail.feature.navigation.drawer.domain.usecase.SyncAccount
import app.k9mail.feature.navigation.drawer.domain.usecase.SyncAllAccounts
import app.k9mail.feature.navigation.drawer.ui.DrawerViewModel
@@ -18,6 +19,11 @@ val navigationDrawerModule: Module = module {
            configProver = get(),
        )
    }
    single<UseCase.SaveDrawerConfig> {
        SaveDrawerConfig(
            drawerConfigWriter = get(),
        )
    }

    single<UseCase.GetDisplayAccounts> {
        GetDisplayAccounts(
@@ -50,6 +56,7 @@ val navigationDrawerModule: Module = module {
    viewModel {
        DrawerViewModel(
            getDrawerConfig = get(),
            saveDrawerConfig = get(),
            getDisplayAccounts = get(),
            getDisplayFoldersForAccount = get(),
            syncAccount = get(),
+4 −0
Original line number Diff line number Diff line
@@ -12,6 +12,10 @@ internal interface DomainContract {
            operator fun invoke(): Flow<DrawerConfig>
        }

        fun interface SaveDrawerConfig {
            operator fun invoke(drawerConfig: DrawerConfig): Flow<Unit>
        }

        fun interface GetDisplayAccounts {
            operator fun invoke(): Flow<List<DisplayAccount>>
        }
+1 −5
Original line number Diff line number Diff line
@@ -4,15 +4,11 @@ import app.k9mail.feature.navigation.drawer.NavigationDrawerExternalContract.Dra
import app.k9mail.feature.navigation.drawer.NavigationDrawerExternalContract.DrawerConfigLoader
import app.k9mail.feature.navigation.drawer.domain.DomainContract.UseCase
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow

internal class GetDrawerConfig(
    private val configProver: DrawerConfigLoader,
) : UseCase.GetDrawerConfig {
    override operator fun invoke(): Flow<DrawerConfig> {
        // TODO This needs to be updated when the config changes
        return flow {
            emit(configProver.loadDrawerConfig())
        }
        return configProver.loadDrawerConfigFlow()
    }
}
Loading