mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor: improve packetResponse performance
This commit is contained in:
parent
15fe0b7cc1
commit
b0f990e42a
2 changed files with 7 additions and 6 deletions
|
|
@ -12,8 +12,8 @@ class MeshLogRepository @Inject constructor(private val meshLogDaoLazy: dagger.L
|
|||
meshLogDaoLazy.get()
|
||||
}
|
||||
|
||||
suspend fun getAllLogs(): Flow<List<MeshLog>> = withContext(Dispatchers.IO) {
|
||||
meshLogDao.getAllLogs(MAX_ITEMS)
|
||||
suspend fun getAllLogs(maxItems: Int = MAX_ITEMS): Flow<List<MeshLog>> = withContext(Dispatchers.IO) {
|
||||
meshLogDao.getAllLogs(maxItems)
|
||||
}
|
||||
|
||||
suspend fun getAllLogsInReceiveOrder(maxItems: Int = MAX_ITEMS): Flow<List<MeshLog>> = withContext(Dispatchers.IO) {
|
||||
|
|
|
|||
|
|
@ -153,10 +153,11 @@ class UIViewModel @Inject constructor(
|
|||
_ourNodeInfo.value = it
|
||||
}.launchIn(viewModelScope)
|
||||
|
||||
combine(meshLog, requestId) { packet, requestId ->
|
||||
if (requestId != null) _packetResponse.value =
|
||||
packet.firstOrNull { it.meshPacket?.decoded?.requestId == requestId }
|
||||
}.launchIn(viewModelScope)
|
||||
viewModelScope.launch {
|
||||
combine(meshLogRepository.getAllLogs(9), requestId) { list, id ->
|
||||
list.takeIf { id != null }?.firstOrNull { it.meshPacket?.decoded?.requestId == id }
|
||||
}.collect { response -> _packetResponse.value = response }
|
||||
}
|
||||
|
||||
debug("ViewModel created")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue