Fixes reply level calculation caching.

This commit is contained in:
Vitor Pamplona
2024-11-01 10:05:25 -04:00
parent 82f0ed8a0d
commit 0581a3e836

View File

@@ -118,11 +118,17 @@ object ThreadLevelCalculator {
if ( if (
note.event is RepostEvent || note.event is GenericRepostEvent || replyTo == null || replyTo.isEmpty() note.event is RepostEvent || note.event is GenericRepostEvent || replyTo == null || replyTo.isEmpty()
) { ) {
cachedLevels[note] = 0
return 0 return 0
} }
return replyTo.maxOf { val thisLevel =
cachedLevels[it] ?: replyLevel(it, cachedLevels).apply { cachedLevels.put(it, this) } replyTo.maxOf {
} + 1 cachedLevels[it] ?: replyLevel(it, cachedLevels)
} + 1
cachedLevels[note] = thisLevel
return thisLevel
} }
} }