diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableRoute.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableRoute.kt index f0c758bf3..1d4264585 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableRoute.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableRoute.kt @@ -375,7 +375,7 @@ fun CustomEmojiChecker( onEmojiText: @Composable (ImmutableList) -> Unit, ) { val mayContainEmoji by remember(text, tags) { - mutableStateOf(CustomEmoji.fastMightContainEmoji(text, tags)) + mutableStateOf(CustomEmoji.fastMightContainEmoji(text, tags?.lists)) } if (mayContainEmoji) { @@ -385,7 +385,7 @@ fun CustomEmojiChecker( } LaunchedEffect(text, tags) { - val newEmojiList = CustomEmoji.assembleAnnotatedList(text, tags) + val newEmojiList = CustomEmoji.assembleAnnotatedList(text, tags?.lists) if (newEmojiList != null) { emojiList = newEmojiList } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/richtext/RichTextParser.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/richtext/RichTextParser.kt index f51662962..70d90061d 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/richtext/RichTextParser.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/richtext/RichTextParser.kt @@ -140,7 +140,7 @@ class RichTextParser { val imageUrls = imagesForPager.filterValues { it is MediaUrlImage }.keys val videoUrls = imagesForPager.filterValues { it is MediaUrlVideo }.keys - val emojiMap = CustomEmoji.createEmojiMap(tags) + val emojiMap = CustomEmoji.createEmojiMap(tags.lists) val segments = findTextSegments(content, imageUrls, videoUrls, urlSet, emojiMap, tags) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip30CustomEmoji/CustomEmoji.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip30CustomEmoji/CustomEmoji.kt index b7d6a1b14..648e23519 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip30CustomEmoji/CustomEmoji.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip30CustomEmoji/CustomEmoji.kt @@ -21,7 +21,6 @@ package com.vitorpamplona.quartz.nip30CustomEmoji import androidx.compose.runtime.Immutable -import com.vitorpamplona.quartz.nip01Core.core.ImmutableListOfLists import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.toImmutableList @@ -32,10 +31,10 @@ class CustomEmoji { fun fastMightContainEmoji( input: String, - allTags: ImmutableListOfLists?, + allTags: Array>?, ): Boolean { if (allTags == null) return false - if (allTags.lists.any { it.size > 2 && it[0] == EmojiUrlTag.TAG_NAME }) return true + if (allTags.any { it.size > 2 && it[0] == EmojiUrlTag.TAG_NAME }) return true return input.contains(":") } @@ -47,7 +46,7 @@ class CustomEmoji { return input.contains(":") } - fun createEmojiMap(tags: ImmutableListOfLists): Map = tags.lists.filter { it.size > 2 && it[0] == EmojiUrlTag.TAG_NAME }.associate { ":${it[1]}:" to it[2] } + fun createEmojiMap(tags: Array>): Map = tags.filter { it.size > 2 && it[0] == EmojiUrlTag.TAG_NAME }.associate { ":${it[1]}:" to it[2] } fun findAllEmojis(input: String): List { val matcher = customEmojiPattern.findAll(input) @@ -67,11 +66,11 @@ class CustomEmoji { fun assembleAnnotatedList( input: String, - allTags: ImmutableListOfLists?, + tags: Array>?, ): ImmutableList? { - if (allTags == null || allTags.lists.isEmpty()) return null + if (tags == null || tags.isEmpty()) return null - val emojiPairs = createEmojiMap(allTags) + val emojiPairs = createEmojiMap(tags) return assembleAnnotatedList(input, emojiPairs) } diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip30CustomEmoji/Nip30Test.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip30CustomEmoji/Nip30Test.kt index 6d443a2ea..41a8e2b07 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip30CustomEmoji/Nip30Test.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip30CustomEmoji/Nip30Test.kt @@ -20,7 +20,6 @@ */ package com.vitorpamplona.quartz.nip30CustomEmoji -import com.vitorpamplona.quartz.nip01Core.core.ImmutableListOfLists import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNull @@ -150,7 +149,7 @@ class Nip30Test { "#ioメシヨソイゲーム\n" + "https://misskey.io/play/9g3qza4jow" - val result = CustomEmoji.assembleAnnotatedList(input, ImmutableListOfLists(tags)) + val result = CustomEmoji.assembleAnnotatedList(input, tags) assertEquals(9, result!!.size)