Use Wholphin-specific dispatchers (#1583)
## Description Switches all usages of `kotlinx.coroutines.Dispatchers` to `WholphinDispatchers`. `WholphinDispatchers` provides an easier and more reliable mechanism to use a test dispatcher in unit tests. For regular app usage, `WholphinDispatchers` just delegates to `Dispatchers`. There are no user facing changes ### Related issues None ### Testing Basic emulator testing & unit tests ## Screenshots N/A ## AI or LLM usage None
This commit is contained in:
parent
ddbec0da73
commit
e17ae3eb8a
68 changed files with 252 additions and 226 deletions
|
|
@ -7,7 +7,7 @@ import com.github.damontecres.wholphin.data.model.PlaybackLanguageChoice
|
|||
import com.github.damontecres.wholphin.data.model.TrackIndex
|
||||
import com.github.damontecres.wholphin.preferences.UserPreferences
|
||||
import com.github.damontecres.wholphin.services.StreamChoiceService
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import com.github.damontecres.wholphin.util.WholphinDispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.jellyfin.sdk.model.api.MediaSourceInfo
|
||||
import org.jellyfin.sdk.model.api.MediaStream
|
||||
|
|
@ -108,7 +108,7 @@ class ItemPlaybackRepository
|
|||
itemId: UUID,
|
||||
sourceId: UUID,
|
||||
): ItemPlayback? =
|
||||
withContext(Dispatchers.IO) {
|
||||
withContext(WholphinDispatchers.IO) {
|
||||
serverRepository.currentUser?.let { user ->
|
||||
val itemPlayback =
|
||||
ItemPlayback(
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ import com.github.damontecres.wholphin.data.model.JellyfinUser
|
|||
import com.github.damontecres.wholphin.preferences.AppPreferences
|
||||
import com.github.damontecres.wholphin.services.hilt.IoDispatcher
|
||||
import com.github.damontecres.wholphin.ui.toServerString
|
||||
import com.github.damontecres.wholphin.util.WholphinDispatchers
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
|
@ -109,7 +109,7 @@ class ServerRepository
|
|||
}.build()
|
||||
}
|
||||
val currentUser = CurrentUser(updatedServer, updatedUser)
|
||||
withContext(Dispatchers.Main) {
|
||||
withContext(WholphinDispatchers.Main) {
|
||||
_current.value = currentUser
|
||||
_currentUserDto.value = userDto
|
||||
}
|
||||
|
|
@ -222,7 +222,7 @@ class ServerRepository
|
|||
|
||||
suspend fun removeUser(user: JellyfinUser) {
|
||||
if (current.value?.user?.id == user.id) {
|
||||
withContext(Dispatchers.Main) {
|
||||
withContext(WholphinDispatchers.Main) {
|
||||
_current.value = null
|
||||
}
|
||||
userPreferencesDataStore.updateData {
|
||||
|
|
@ -241,7 +241,7 @@ class ServerRepository
|
|||
|
||||
suspend fun removeServer(server: JellyfinServer) {
|
||||
if (current.value?.server?.id == server.id) {
|
||||
withContext(Dispatchers.Main) {
|
||||
withContext(WholphinDispatchers.Main) {
|
||||
_current.value = null
|
||||
}
|
||||
userPreferencesDataStore.updateData {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue