diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt index 2c10bb3dc..eb8c745ce 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt @@ -2178,6 +2178,8 @@ object LocalCache { val childrenToBeRemoved = mutableListOf() toBeRemoved.forEach { + // TODO: NEED TO TEST IF WRAPS COME BACK WHEN NEEDED BEFORE ACTIVATING + // childrenToBeRemoved.addAll(removeIfWrap(it)) removeFromCache(it) childrenToBeRemoved.addAll(it.removeAllChildNotes()) @@ -2194,6 +2196,24 @@ object LocalCache { } } + fun removeIfWrap(note: Note): List { + val noteEvent = note.event + + val children = + if (noteEvent is WrappedEvent) { + noteEvent.host?.id?.let { + getNoteIfExists(it)?.let { + removeFromCache(it) + it.removeAllChildNotes() + } + } + } else { + null + } + + return children ?: emptyList() + } + fun prunePastVersionsOfReplaceables() { val toBeRemoved = notes.filter { _, note ->