Skip to content

Commit 452b3c4

Browse files
ShaanNarendrandavid-allison
authored andcommitted
Fix: Optimize toggleCollapsed UI performance
1 parent 29ae69f commit 452b3c4

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

AnkiDroid/src/main/java/com/ichi2/anki/tags/ManageTagsViewModel.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,11 @@ class ManageTagsViewModel : ViewModel() {
117117
}
118118
val newCollapsed = !node.collapsed
119119
withCol { tags.setCollapsed(tag, newCollapsed) }
120-
// re-fetch tree to get updated collapsed state
121-
tagList = flattenTree(withCol { tags.tree() })
120+
// Update the in-memory list with the new collapsed state
121+
tagList =
122+
tagList.map {
123+
if (it.fullTag == tag) it.copy(collapsed = newCollapsed) else it
124+
}
122125
updateState { it.copy(visibleNodes = computeVisibleNodes(it.searchQuery)) }
123126
} catch (e: CancellationException) {
124127
throw e

0 commit comments

Comments
 (0)