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

Unverified Commit c1a817a5 authored by Rafael Tonholo's avatar Rafael Tonholo
Browse files

refactor(outbox): use OutboxFolderManager to retrieve the outbox id in DefaultFolderProvider

parent ef1d852b
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
package com.fsck.k9.ui.messagelist

import net.thunderbird.core.android.account.LegacyAccountDto
import net.thunderbird.feature.mail.folder.api.OutboxFolderManager

/**
 * Decides which folder to display when an account is selected.
 */
class DefaultFolderProvider {
class DefaultFolderProvider(
    private val outboxFolderManager: OutboxFolderManager,
) {
    fun getDefaultFolder(account: LegacyAccountDto): Long {
        // Until the UI can handle the case where no remote folders have been fetched yet, we fall back to the Outbox
        // which should always exist.
        return account.autoExpandFolderId ?: account.inboxFolderId ?: account.outboxFolderId ?: error("Outbox missing")
        return account.autoExpandFolderId
            ?: account.inboxFolderId
            ?: outboxFolderManager.getOutboxFolderIdSync(account.id).takeIf { it != -1L }
            ?: error("Outbox missing")
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ val messageListUiModule = module {
    includes(navigationDropDownDrawerModule, navigationSideRailDrawerModule)

    viewModel { MessageListViewModel(messageListLiveDataFactory = get(), logger = get()) }
    factory { DefaultFolderProvider() }
    factory { DefaultFolderProvider(outboxFolderManager = get()) }
    factory {
        MessageListLoader(
            accountManager = get(),