diff --git a/core/data/src/main/kotlin/app/pachli/core/data/repository/NetworkListsRepository.kt b/core/data/src/main/kotlin/app/pachli/core/data/repository/NetworkListsRepository.kt index f4c09c98e..198d62588 100644 --- a/core/data/src/main/kotlin/app/pachli/core/data/repository/NetworkListsRepository.kt +++ b/core/data/src/main/kotlin/app/pachli/core/data/repository/NetworkListsRepository.kt @@ -29,11 +29,10 @@ import app.pachli.core.network.model.MastoList import app.pachli.core.network.model.TimelineAccount import app.pachli.core.network.model.UserListRepliesPolicy import app.pachli.core.network.retrofit.MastodonApi -import com.github.michaelbull.result.Err import com.github.michaelbull.result.Ok import com.github.michaelbull.result.Result import com.github.michaelbull.result.coroutines.binding.binding -import com.github.michaelbull.result.mapBoth +import com.github.michaelbull.result.mapEither import com.github.michaelbull.result.mapError import javax.inject.Inject import javax.inject.Singleton @@ -61,12 +60,12 @@ class NetworkListsRepository @Inject constructor( externalScope.launch { _lists.value = Ok(Lists.Loading) _lists.value = api.getLists() - .mapBoth( + .mapEither( { updateTabPreferences(it.body.associateBy { it.id }) - Ok(Lists.Loaded(it.body)) + Lists.Loaded(it.body) }, - { Err(Retrieve(it)) }, + { Retrieve(it) }, ) } } diff --git a/feature/lists/src/main/kotlin/app/pachli/feature/lists/AccountsInListViewModel.kt b/feature/lists/src/main/kotlin/app/pachli/feature/lists/AccountsInListViewModel.kt index bcfe3c701..7939022b4 100644 --- a/feature/lists/src/main/kotlin/app/pachli/feature/lists/AccountsInListViewModel.kt +++ b/feature/lists/src/main/kotlin/app/pachli/feature/lists/AccountsInListViewModel.kt @@ -24,10 +24,10 @@ import app.pachli.core.data.repository.ListsRepository import app.pachli.core.network.model.TimelineAccount import app.pachli.core.network.retrofit.MastodonApi import app.pachli.core.network.retrofit.apiresult.ApiError -import com.github.michaelbull.result.Err import com.github.michaelbull.result.Ok import com.github.michaelbull.result.Result -import com.github.michaelbull.result.mapBoth +import com.github.michaelbull.result.map +import com.github.michaelbull.result.mapEither import com.github.michaelbull.result.onFailure import com.github.michaelbull.result.onSuccess import dagger.assisted.Assisted @@ -82,11 +82,10 @@ class AccountsInListViewModel @AssistedInject constructor( fun refresh() = viewModelScope.launch { _accountsInList.value = Ok(Accounts.Loading) _accountsInList.value = listsRepository.getAccountsInList(listId) - .mapBoth({ - Ok(Accounts.Loaded(it)) - }, { - Err(FlowError.GetAccounts(it)) - }) + .mapEither( + { Accounts.Loaded(it) }, + { FlowError.GetAccounts(it) }, + ) } /** @@ -120,11 +119,8 @@ class AccountsInListViewModel @AssistedInject constructor( query.isEmpty() -> _searchResults.value = Ok(SearchResults.Empty) query.isBlank() -> _searchResults.value = Ok(SearchResults.Loaded(emptyList())) else -> viewModelScope.launch { - _searchResults.value = api.searchAccounts(query, null, 10, true).mapBoth({ - Ok(SearchResults.Loaded(it.body)) - }, { - Err(it) - }) + _searchResults.value = api.searchAccounts(query, null, 10, true) + .map { SearchResults.Loaded(it.body) } } } }