Moves uncited hashtag parsing to a thread

This commit is contained in:
Vitor Pamplona
2024-06-19 12:36:09 -04:00
parent a0271a2982
commit d39d1239f6
@@ -37,7 +37,7 @@ import com.vitorpamplona.amethyst.ui.theme.lessImportantLink
import com.vitorpamplona.quartz.events.Event import com.vitorpamplona.quartz.events.Event
import com.vitorpamplona.quartz.events.toImmutableListOfLists import com.vitorpamplona.quartz.events.toImmutableListOfLists
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.launch
@Composable @Composable
fun DisplayUncitedHashtags( fun DisplayUncitedHashtags(
@@ -56,12 +56,10 @@ fun DisplayUncitedHashtags(
) { ) {
val unusedHashtags by val unusedHashtags by
produceState(initialValue = emptyList<String>()) { produceState(initialValue = emptyList<String>()) {
withContext(Dispatchers.Default) {
val state = CachedRichTextParser.parseText(content, event.tags.toImmutableListOfLists())
val tagsInEvent = event.hashtags() val tagsInEvent = event.hashtags()
if (tagsInEvent.isNotEmpty()) {
if (tagsInEvent.isEmpty()) return@withContext launch(Dispatchers.Default) {
val state = CachedRichTextParser.parseText(content, event.tags.toImmutableListOfLists())
val tagsInContent = val tagsInContent =
state state
@@ -88,6 +86,7 @@ fun DisplayUncitedHashtags(
} }
} }
} }
}
if (unusedHashtags.isNotEmpty()) { if (unusedHashtags.isNotEmpty()) {
val style = val style =