Added type check in complex rebind

commit_hash:bc6c3cfa3f3c4ffaafec97a3f61d47871fd35a58
This commit is contained in:
pkurchatov
2025-02-14 13:32:13 +03:00
parent 63daf707bc
commit ecaf4fbf4b
2 changed files with 8 additions and 3 deletions
@@ -85,7 +85,7 @@ internal class RebindTask(
lastExistingParent = null,
)
if (existingToken.divHash == newToken.divHash) {
if (existingToken.isCombinable(newToken)) {
doNodeInSameMode(existingToken, newToken)
} else {
doNodeInExistingMode(existingToken)
@@ -116,7 +116,7 @@ internal class RebindTask(
val aloneExistingChild = mutableListOf<ExistingToken>()
existingToken.getChildrenTokens(combinedToken).forEach { existingChild ->
val newChildWithSameHash = aloneNewChild.find { it.divHash == existingChild.divHash }
val newChildWithSameHash = aloneNewChild.find { it.isCombinable(existingChild) }
if (newChildWithSameHash != null) {
doNodeInSameMode(existingChild, newChildWithSameHash)
@@ -155,7 +155,7 @@ internal class RebindTask(
}
private fun doNodeInNewMode(newToken: NewToken) {
val existingWithSameHash = aloneExisting.find { it.divHash == newToken.divHash }
val existingWithSameHash = aloneExisting.find { it.isCombinable(newToken) }
if (existingWithSameHash != null) {
aloneExisting.remove(existingWithSameHash)
@@ -1,5 +1,6 @@
package com.yandex.div.core.view2.reuse
import com.yandex.div.core.util.type
import com.yandex.div.internal.core.DivItemBuilderResult
internal abstract class Token(
@@ -8,4 +9,8 @@ internal abstract class Token(
) {
val divHash: Int = item.div.propertiesHash()
val div = item.div
fun isCombinable(other: Token): Boolean {
return divHash == other.divHash && div.type == other.div.type
}
}