Offline/playback recording robustness (contract-audit follow-ups) #90

Merged
bvandeusen merged 2 commits from dev into main 2026-06-11 14:19:27 -04:00
Showing only changes of commit 4ecb1680bf - Show all commits
@@ -135,15 +135,18 @@ class MutationReplayer @Inject constructor(
private fun supersededLikeToggleIds(rows: List<CachedMutationEntity>): Set<Long> { private fun supersededLikeToggleIds(rows: List<CachedMutationEntity>): Set<Long> {
val latestByEntity = HashMap<String, Long>() val latestByEntity = HashMap<String, Long>()
val superseded = HashSet<Long>() val superseded = HashSet<Long>()
for (row in rows) { rows.asSequence()
if (row.kind != MutationKind.LIKE_TOGGLE) continue .filter { it.kind == MutationKind.LIKE_TOGGLE }
val decoded = runCatching { .forEach { row ->
json.decodeFromString(LikeTogglePayload.serializer(), row.payload) val decoded = runCatching {
}.getOrNull() ?: continue json.decodeFromString(LikeTogglePayload.serializer(), row.payload)
val key = "${decoded.entityType}:${decoded.entityId}" }.getOrNull()
// `rows` is ascending by id, so a prior entry is always older. if (decoded != null) {
latestByEntity.put(key, row.id)?.let(superseded::add) val key = "${decoded.entityType}:${decoded.entityId}"
} // `rows` is ascending by id, so a prior entry is always older.
latestByEntity.put(key, row.id)?.let(superseded::add)
}
}
return superseded return superseded
} }