Parallelize initial overview sync
This commit is contained in:
1 parent
bba051bf14
commit
2754dada42
2 files changed
+19
-6
No files matched your search
@@ -9,6 +9,8 @@ import cn.xiaobai.openclawapp.data.RemoteOpenClawRepository
|
||||
import cn.xiaobai.openclawapp.data.RepositoryFactory
|
||||
import cn.xiaobai.openclawapp.data.ServerConfig
|
||||
import cn.xiaobai.openclawapp.network.MobileGatewayApi
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
|
||||
class OpenClawAppState(
|
||||
private val preferences: AppPreferences = AppPreferences(),
|
||||
@@ -106,9 +108,14 @@ class OpenClawAppState(
|
||||
isSyncing = true
|
||||
syncError = null
|
||||
runCatching {
|
||||
remote.refreshStatus()
|
||||
remote.refreshAgents()
|
||||
remote.refreshSessions()
|
||||
coroutineScope {
|
||||
val statusDeferred = async { remote.refreshStatus() }
|
||||
val agentsDeferred = async { remote.refreshAgents() }
|
||||
val sessionsDeferred = async { remote.refreshSessions() }
|
||||
statusDeferred.await()
|
||||
agentsDeferred.await()
|
||||
sessionsDeferred.await()
|
||||
}
|
||||
val drainedText = remote.drainPendingTextQueue()
|
||||
val drainedAttachments = remote.drainPendingAttachmentQueue()
|
||||
preferences.saveOverviewSnapshot(remote.exportOverviewSnapshot())
|
||||
@@ -130,9 +137,14 @@ class OpenClawAppState(
|
||||
if (isSyncing || sendingSessionId != null) return
|
||||
|
||||
runCatching {
|
||||
remote.refreshStatus()
|
||||
remote.refreshAgents()
|
||||
remote.refreshSessions()
|
||||
coroutineScope {
|
||||
val statusDeferred = async { remote.refreshStatus() }
|
||||
val agentsDeferred = async { remote.refreshAgents() }
|
||||
val sessionsDeferred = async { remote.refreshSessions() }
|
||||
statusDeferred.await()
|
||||
agentsDeferred.await()
|
||||
sessionsDeferred.await()
|
||||
}
|
||||
preferences.saveOverviewSnapshot(remote.exportOverviewSnapshot())
|
||||
persistPendingSendQueue(remote)
|
||||
isShowingCachedData = false
|
||||
|
||||
Reference in new issue
Block a user