@@ -9,6 +9,8 @@ import kotlinx.coroutines.coroutineScope
99import kotlinx.coroutines.delay
1010import kotlinx.coroutines.flow.MutableStateFlow
1111import kotlinx.coroutines.withContext
12+ import kotlinx.serialization.json.JsonArray
13+ import kotlinx.serialization.json.JsonObject
1214import li.songe.gkd.a11y.TopActivity
1315import li.songe.gkd.a11y.screenshot
1416import li.songe.gkd.a11y.topActivityFlow
@@ -32,21 +34,25 @@ object SnapshotExt {
3234 return snapshotParentPath(id).resolve(" ${id} .min.json" )
3335 }
3436
35- suspend fun getMinSnapshot (id : Long ): ComplexSnapshot {
37+ suspend fun getMinSnapshot (id : Long ): JsonObject {
3638 val f = minSnapshotFile(id)
3739 if (! f.exists()) {
3840 val text = withContext(Dispatchers .IO ) { snapshotFile(id).readText() }
39- val snapshot = withContext(Dispatchers .Default ) {
40- json.decodeFromString<ComplexSnapshot >(text)
41+ val snapshotJson = withContext(Dispatchers .Default ) {
42+ // #1185
43+ json.decodeFromString<JsonObject >(text)
4144 }
42- val minSnapshot = snapshot.copy(nodes = emptyList())
45+ val minSnapshot = JsonObject (snapshotJson.toMutableMap().apply {
46+ this [" nodes" ] = JsonArray (emptyList())
47+ })
4348 withContext(Dispatchers .IO ) {
4449 f.writeText(keepNullJson.encodeToString(minSnapshot))
4550 }
51+ return minSnapshot
4652 }
4753 val text = withContext(Dispatchers .IO ) { f.readText() }
4854 return withContext(Dispatchers .Default ) {
49- json.decodeFromString<ComplexSnapshot >(text)
55+ json.decodeFromString<JsonObject >(text)
5056 }
5157 }
5258
0 commit comments