Solves the sorting contract crash by precaching all values before sorting.

This commit is contained in:
Vitor Pamplona
2026-03-12 10:45:54 -04:00
parent a94d5bfd07
commit 3eb2fcbcb8
@@ -2298,12 +2298,17 @@ object LocalCache : ILocalCache, ICacheProvider {
} }
} }
val findsFollowing = finds.associateWith { forAccount?.isFollowing(it) == true }
val anyNameStartsWith = finds.associateWith { it.metadataOrNull()?.anyNameStartsWith(dualCase) == true }
val anyAddressStartsWith = finds.associateWith { it.metadataOrNull()?.anyAddressStartsWith(dualCase) == true }
val displayNames = finds.associateWith { it.toBestDisplayName().lowercase() }
return finds.sortedWith( return finds.sortedWith(
compareBy( compareBy(
{ forAccount?.isFollowing(it) == false }, { findsFollowing[it] == false },
{ it.metadataOrNull()?.anyNameStartsWith(dualCase) == false }, { anyNameStartsWith[it] == false },
{ it.metadataOrNull()?.anyAddressStartsWith(dualCase) == false }, { anyAddressStartsWith[it] == false },
{ it.toBestDisplayName().lowercase() }, { displayNames[it] },
{ it.pubkeyHex }, { it.pubkeyHex },
), ),
) )