Moves uncited hashtag parsing to a thread
This commit is contained in:
+24
-25
@@ -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,35 +56,34 @@ fun DisplayUncitedHashtags(
|
|||||||
) {
|
) {
|
||||||
val unusedHashtags by
|
val unusedHashtags by
|
||||||
produceState(initialValue = emptyList<String>()) {
|
produceState(initialValue = emptyList<String>()) {
|
||||||
withContext(Dispatchers.Default) {
|
val tagsInEvent = event.hashtags()
|
||||||
val state = CachedRichTextParser.parseText(content, event.tags.toImmutableListOfLists())
|
if (tagsInEvent.isNotEmpty()) {
|
||||||
|
launch(Dispatchers.Default) {
|
||||||
|
val state = CachedRichTextParser.parseText(content, event.tags.toImmutableListOfLists())
|
||||||
|
|
||||||
val tagsInEvent = event.hashtags()
|
val tagsInContent =
|
||||||
|
state
|
||||||
if (tagsInEvent.isEmpty()) return@withContext
|
.paragraphs
|
||||||
|
.map {
|
||||||
val tagsInContent =
|
it.words.mapNotNull {
|
||||||
state
|
if (it is HashTagSegment) {
|
||||||
.paragraphs
|
it.hashtag
|
||||||
.map {
|
} else {
|
||||||
it.words.mapNotNull {
|
null
|
||||||
if (it is HashTagSegment) {
|
}
|
||||||
it.hashtag
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
}
|
||||||
|
}.flatten()
|
||||||
|
|
||||||
|
val unusedHashtags =
|
||||||
|
tagsInEvent.filterNot { eventTag ->
|
||||||
|
tagsInContent.any { contentTag ->
|
||||||
|
eventTag.equals(contentTag, true)
|
||||||
}
|
}
|
||||||
}.flatten()
|
|
||||||
|
|
||||||
val unusedHashtags =
|
|
||||||
tagsInEvent.filterNot { eventTag ->
|
|
||||||
tagsInContent.any { contentTag ->
|
|
||||||
eventTag.equals(contentTag, true)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (unusedHashtags.isNotEmpty()) {
|
if (unusedHashtags.isNotEmpty()) {
|
||||||
value = unusedHashtags
|
value = unusedHashtags
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user