Skip to content

Commit

Permalink
Quicker auto-discovery
Browse files Browse the repository at this point in the history
Immediately show server chooser after the first server has been discovered, replace withContext() with flowOn()
  • Loading branch information
Maxr1998 committed Sep 20, 2020
1 parent df24a1d commit bc6ea9b
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions app/src/main/java/org/jellyfin/mobile/webapp/ConnectionHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ import androidx.core.view.postDelayed
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
import org.jellyfin.apiclient.Jellyfin
Expand Down Expand Up @@ -147,12 +146,10 @@ class ConnectionHelper(private val activity: MainActivity) : KoinComponent {

private fun discoverServers() {
activity.lifecycleScope.launch {
withContext(Dispatchers.IO) {
jellyfin.discovery.discover().onEach {
serverList.add(it)
}.collect()
jellyfin.discovery.discover().flowOn(Dispatchers.IO).collect { serverInfo ->
serverList.add(serverInfo)
chooseServerButton.isVisible = true
}
chooseServerButton.isVisible = serverList.isNotEmpty()
}
}

Expand Down

0 comments on commit bc6ea9b

Please sign in to comment.