mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
fix: network discovery list concurrency handling
This commit is contained in:
parent
1a24ebc9d5
commit
49e0d32fa4
1 changed files with 6 additions and 3 deletions
|
|
@ -14,6 +14,7 @@ import kotlinx.coroutines.flow.Flow
|
|||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.callbackFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
|
@ -51,9 +52,11 @@ class NetworkRepository @Inject constructor(
|
|||
processLifecycle.coroutineScope.launch(dispatchers.default) {
|
||||
nsdManagerLazy.get()?.let { manager ->
|
||||
manager.discoverServices(SERVICE_TYPE).collect { serviceList ->
|
||||
_resolvedList.value = serviceList
|
||||
.filter { it.serviceName == SERVICE_NAME }
|
||||
.mapNotNull { manager.resolveService(it) }
|
||||
_resolvedList.update {
|
||||
serviceList
|
||||
.filter { it.serviceName == SERVICE_NAME }
|
||||
.mapNotNull { manager.resolveService(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue