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:
eliotcougar
2026-08-19 13:57:06 +08:00
committed by GitHub
parent 06a27ec4d4
commit 3c91b51489
@@ -689,11 +689,17 @@ class MainViewModel(
dataSource.cancelAllPing()
val groupId = uiState.value.selectedGroupId
val servers = currentServers()
dataSource.clearAllTestDelayResults(servers.map { it.guid })
if (servers.isEmpty()) {
_uiState.update { it.copy(isTesting = false) }
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
_uiState.update {
it.copy(
@@ -702,12 +708,13 @@ class MainViewModel(
)
}
viewModelScope.launch(ioDispatcher) {
dataSource.clearAllTestDelayResults(serverGuids)
cacheMutex.withLock { groupDataCache.remove(groupId) }
dataSource.sendMsg2TestService(
TestServiceMessage(
key = AppConfig.MSG_MEASURE_CONFIG_START,
subscriptionId = groupId,
serverGuids = if (keywordFilter.isNotEmpty()) servers.map { it.guid } else emptyList(),
serverGuids = if (keywordFilter.isNotEmpty()) serverGuids else emptyList(),
onlyTcp = onlyTcp
)
)