Optimize large-group probing startup (#6102)
Clear visible delays immediately, but move the per-profile MMKV reset to the existing I/O coroutine. Finish the reset before starting the test service so newly reported results cannot be erased.
This commit is contained in:
1 parent
06a27ec4d4
commit
3c91b51489
1 file changed
+9
-2
@@ -689,11 +689,17 @@ class MainViewModel(
|
|||||||
dataSource.cancelAllPing()
|
dataSource.cancelAllPing()
|
||||||
val groupId = uiState.value.selectedGroupId
|
val groupId = uiState.value.selectedGroupId
|
||||||
val servers = currentServers()
|
val servers = currentServers()
|
||||||
dataSource.clearAllTestDelayResults(servers.map { it.guid })
|
|
||||||
if (servers.isEmpty()) {
|
if (servers.isEmpty()) {
|
||||||
_uiState.update { it.copy(isTesting = false) }
|
_uiState.update { it.copy(isTesting = false) }
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
val serverGuids = servers.map { it.guid }
|
||||||
|
mutableServersForGroup(groupId).update { current ->
|
||||||
|
current.map { server ->
|
||||||
|
if (server.testDelayMillis == 0L) server
|
||||||
|
else server.copy(testDelayMillis = 0L)
|
||||||
|
}
|
||||||
|
}
|
||||||
testingGroupId = groupId
|
testingGroupId = groupId
|
||||||
_uiState.update {
|
_uiState.update {
|
||||||
it.copy(
|
it.copy(
|
||||||
@@ -702,12 +708,13 @@ class MainViewModel(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
viewModelScope.launch(ioDispatcher) {
|
viewModelScope.launch(ioDispatcher) {
|
||||||
|
dataSource.clearAllTestDelayResults(serverGuids)
|
||||||
cacheMutex.withLock { groupDataCache.remove(groupId) }
|
cacheMutex.withLock { groupDataCache.remove(groupId) }
|
||||||
dataSource.sendMsg2TestService(
|
dataSource.sendMsg2TestService(
|
||||||
TestServiceMessage(
|
TestServiceMessage(
|
||||||
key = AppConfig.MSG_MEASURE_CONFIG_START,
|
key = AppConfig.MSG_MEASURE_CONFIG_START,
|
||||||
subscriptionId = groupId,
|
subscriptionId = groupId,
|
||||||
serverGuids = if (keywordFilter.isNotEmpty()) servers.map { it.guid } else emptyList(),
|
serverGuids = if (keywordFilter.isNotEmpty()) serverGuids else emptyList(),
|
||||||
onlyTcp = onlyTcp
|
onlyTcp = onlyTcp
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in new issue
Block a user