Skip to content

Commit

Permalink
PR feedback: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dzolnai committed Oct 13, 2023
1 parent d26285f commit 47aa439
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package nl.eduvpn.app.service

import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.withContext
import nl.eduvpn.app.entity.OrganizationList
import nl.eduvpn.app.entity.ServerList
Expand All @@ -27,8 +26,10 @@ import org.json.JSONObject
* Service which provides the configurations for organization related data model.
* Created by Daniel Zolnai on 2016-10-07.
*/
class OrganizationService(private val serializerService: SerializerService,
private val backendService: BackendService) {
class OrganizationService(
private val serializerService: SerializerService,
private val backendService: BackendService
) {


suspend fun fetchServerList() : ServerList = withContext(Dispatchers.IO) {
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/nl/eduvpn/app/viewmodel/MainViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class MainViewModel @Inject constructor(
data class SelectCountry(val cookie: Int?) : MainParentAction()
data class SelectProfiles(val profileList: List<Profile>): MainParentAction()
data class ConnectWithConfig(val config: SerializedVpnConfig) : MainParentAction()

data class ShowError(val throwable: Throwable) : MainParentAction()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ package nl.eduvpn.app.viewmodel
import android.content.Context
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import androidx.lifecycle.map
import androidx.lifecycle.switchMap
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -101,7 +103,7 @@ class OrganizationSelectionViewModel @Inject constructor(
val lastKnownServerListVersion = preferencesService.getLastKnownServerListVersion()

val organizationList =
runCatchingCoroutine() { organizationListDeferred.await() }.getOrElse {
runCatchingCoroutine { organizationListDeferred.await() }.getOrElse {
Log.w(TAG, "Organizations call has failed!", it)
OrganizationList(-1L, emptyList())
}
Expand Down Expand Up @@ -177,10 +179,10 @@ class OrganizationSelectionViewModel @Inject constructor(
})
}

val adapterItems = Transformations.switchMap(organizations) { organizations ->
Transformations.switchMap(instituteAccessServers) { instituteAccessServers ->
Transformations.switchMap(secureInternetServers) { secureInternetServers ->
Transformations.map(searchText) { searchText ->
val adapterItems = organizations.switchMap { organizations ->
instituteAccessServers.switchMap { instituteAccessServers ->
secureInternetServers.switchMap { secureInternetServers ->
searchText.map { searchText ->
val resultList = mutableListOf<OrganizationAdapter.OrganizationAdapterItem>()
// Search contains at least two dots
if (searchText.count { ".".contains(it) } > 1) {
Expand Down

0 comments on commit 47aa439

Please sign in to comment.