fix: data sync delay

This commit is contained in:
hstyi
2025-06-30 00:35:26 +08:00
committed by hstyi
parent e21e9f9ed9
commit b1e62952f5

View File

@@ -179,6 +179,11 @@ class NewHostTreeModel private constructor() : SimpleTreeModel<Host>(
source: DatabaseChangedExtension.Source
) {
// 同步数据
if (type == DataType.Host.name && id.isNotBlank()) {
syncUserObject(id)
}
if (id.isBlank() || source != DatabaseChangedExtension.Source.Sync) return
if (type.isNotBlank() && type != DataType.Host.name) return
@@ -213,6 +218,16 @@ class NewHostTreeModel private constructor() : SimpleTreeModel<Host>(
}
}
}
private fun syncUserObject(id: String) {
for (node in getRoot().getAllChildren()) {
if (node.id == id) {
val host = hostManager.getHost(id) ?: return
node.host = host
return
}
}
}
}
private inner class MyAccountAccountExtension : AccountExtension {