Skip to content

Commit

Permalink
fix: some DiskReadViolation (#2097)
Browse files Browse the repository at this point in the history
  • Loading branch information
ohassine authored Sep 27, 2023
1 parent 0049b61 commit f75a3f3
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ import com.wire.kalium.logic.data.session.SessionRepository
import com.wire.kalium.logic.data.team.Team
import com.wire.kalium.logic.data.user.SelfUser
import com.wire.kalium.logic.feature.UserSessionScopeProvider
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.IO
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.flowOn

/**
* This gets and observes the list of valid accounts, and it's associated team.
Expand All @@ -42,7 +45,8 @@ interface ObserveValidAccountsUseCase {

internal class ObserveValidAccountsUseCaseImpl internal constructor(
private val sessionRepository: SessionRepository,
private val userSessionScopeProvider: UserSessionScopeProvider
private val userSessionScopeProvider: UserSessionScopeProvider,
private val ioDispatcher: CoroutineDispatcher = Dispatchers.IO
) : ObserveValidAccountsUseCase {

@OptIn(ExperimentalCoroutinesApi::class)
Expand All @@ -58,5 +62,5 @@ internal class ObserveValidAccountsUseCaseImpl internal constructor(
}
combine(flowsOfSelfUsers) { it.asList() }
}
}
}.flowOn(ioDispatcher)
}

0 comments on commit f75a3f3

Please sign in to comment.