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

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

Change use case to operator function for easier use

parent 913a7e05
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ interface DomainContract {

    interface UseCase {
        fun interface GetDisplayAccounts {
            fun execute(): Flow<List<DisplayAccount>>
            operator fun invoke(): Flow<List<DisplayAccount>>
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ class GetDisplayAccounts(
) : UseCase.GetDisplayAccounts {

    @OptIn(ExperimentalCoroutinesApi::class)
    override fun execute(): Flow<List<DisplayAccount>> {
    override fun invoke(): Flow<List<DisplayAccount>> {
        return accountManager.getAccountsFlow()
            .flatMapLatest { accounts ->
                val messageCountsFlows: List<Flow<MessageCounts>> = accounts.map { account ->
+1 −1
Original line number Diff line number Diff line
@@ -9,5 +9,5 @@ import app.k9mail.feature.navigation.drawer.domain.entity.DisplayAccount
class AccountsViewModel(
    getDisplayAccounts: UseCase.GetDisplayAccounts,
) : ViewModel() {
    val displayAccountsLiveData: LiveData<List<DisplayAccount>> = getDisplayAccounts.execute().asLiveData()
    val displayAccountsLiveData: LiveData<List<DisplayAccount>> = getDisplayAccounts().asLiveData()
}