diff --git a/app/src/main/java/ru/herobrine1st/e621/api/BBCodeProcessor.kt b/app/src/main/java/ru/herobrine1st/e621/api/BBCodeProcessor.kt index 1492ee35..d4295d4f 100644 --- a/app/src/main/java/ru/herobrine1st/e621/api/BBCodeProcessor.kt +++ b/app/src/main/java/ru/herobrine1st/e621/api/BBCodeProcessor.kt @@ -48,7 +48,7 @@ val ITALIC = SpanStyle( const val WIKI_PAGE_STRING_ANNOTATION_TAG = "WIKI_PAGE" @Immutable -sealed interface MessageData> { +sealed interface MessageData { fun isEmpty(): Boolean } @@ -59,7 +59,7 @@ sealed interface MessageData> { @Immutable data class MessageText( val text: AnnotatedString, -) : MessageData { +) : MessageData { constructor(text: String) : this(AnnotatedString(text)) @@ -76,14 +76,14 @@ data class MessageText( @Immutable data class MessageQuote( val author: Author?, - val data: List> -) : MessageData { + val data: List, +) : MessageData { override fun isEmpty(): Boolean = data.isEmpty() @Immutable data class Author( val userName: String, - val userId: Int + val userId: Int, ) } @@ -97,10 +97,10 @@ private sealed interface DTextTag { * @param data list of parsed [MessageData] * @return styled list of [MessageData] */ - fun stylize(data: List>): List> + fun stylize(data: List): List sealed class Styled(override val name: String, private val style: SpanStyle) : DTextTag { - override fun stylize(data: List>): List> { + override fun stylize(data: List): List { return data.map { (it as? MessageText)?.text?.let { text -> MessageText(AnnotatedString.Builder().apply { @@ -119,7 +119,7 @@ private sealed interface DTextTag { data object Quote : DTextTag { override val name: String = "quote" - override fun stylize(data: List>): List> { + override fun stylize(data: List): List { val collapsed = data.collapseMessageTexts().toMutableList() val first = collapsed[0] val author: MessageQuote.Author? @@ -143,7 +143,7 @@ private sealed interface DTextTag { val commaAttribute: String, val property: String ) : DTextTag { - override fun stylize(data: List>): List> { + override fun stylize(data: List): List { val startingTag = "[$name" + (if (commaAttribute.isNotBlank()) ",$commaAttribute" else "") + @@ -178,7 +178,7 @@ private sealed interface DTextTag { else -> Unknown(name, commaAttribute, property) } - fun DTextTag?.stylizeNullable(data: List>) = this?.stylize(data) ?: data + fun DTextTag?.stylizeNullable(data: List) = this?.stylize(data) ?: data } } @@ -197,7 +197,7 @@ val pattern = // name said: val quotePattern = Regex("""(?:"?([^"\n]+)"?:/user(?:s|/show)/(\d+)|(\S+)) said:\r?\n""") -fun parseBBCode(input: String): List> { +fun parseBBCode(input: String): List { val (parsed, end) = parseBBCodeInternal(input, null, 0) assert(end == input.length) { "Parser hasn't reached end of string: expected ${input.length}, actual $end" @@ -209,9 +209,9 @@ fun parseBBCode(input: String): List> { private fun parseBBCodeInternal( input: String, currentTag: DTextTag?, - initialStart: Int -): Pair>, Int> { - val output = mutableListOf>() + initialStart: Int, +): Pair, Int> { + val output = mutableListOf() var start = initialStart var tagClosed = false @@ -293,7 +293,7 @@ private fun parseQuoteHeader(input: String): Pair? { * * @return Optimized list of [MessageData] */ -private fun List>.collapseMessageTexts(): List> { +private fun List.collapseMessageTexts(): List { // FAST PATH: Short comment, maybe with one quote or picture. if (this.size < 2) return this .filter { (it as? MessageText)?.text?.isNotEmpty() != false } diff --git a/app/src/main/java/ru/herobrine1st/e621/api/common/CommentData.kt b/app/src/main/java/ru/herobrine1st/e621/api/common/CommentData.kt index fbab501d..dba2da97 100644 --- a/app/src/main/java/ru/herobrine1st/e621/api/common/CommentData.kt +++ b/app/src/main/java/ru/herobrine1st/e621/api/common/CommentData.kt @@ -36,7 +36,7 @@ data class CommentData( val editTime: Instant, val score: Int, val isHidden: Boolean, - val message: List> + val message: List, ) { companion object { fun fromE621Comment(comment: CommentBB, authorAvatarPost: PostReduced?) = diff --git a/app/src/main/java/ru/herobrine1st/e621/navigation/component/WikiComponent.kt b/app/src/main/java/ru/herobrine1st/e621/navigation/component/WikiComponent.kt index 61c2ccb6..65b23928 100644 --- a/app/src/main/java/ru/herobrine1st/e621/navigation/component/WikiComponent.kt +++ b/app/src/main/java/ru/herobrine1st/e621/navigation/component/WikiComponent.kt @@ -136,10 +136,10 @@ sealed interface WikiState { @Serializable class Success(val result: WikiPage) : WikiState { @Transient // it is a cache - lateinit var parsed: List> + lateinit var parsed: List private set - fun setParsed(v: List>) { + fun setParsed(v: List) { if (::parsed.isInitialized) throw RuntimeException("This property is write-once") parsed = v } diff --git a/app/src/main/java/ru/herobrine1st/e621/ui/component/RenderBB.kt b/app/src/main/java/ru/herobrine1st/e621/ui/component/RenderBB.kt index f31aa81e..c873603f 100644 --- a/app/src/main/java/ru/herobrine1st/e621/ui/component/RenderBB.kt +++ b/app/src/main/java/ru/herobrine1st/e621/ui/component/RenderBB.kt @@ -71,7 +71,7 @@ fun RenderBB(text: String, onWikiLinkClick: ((Tag) -> Unit)? = null) { } @Composable -fun RenderBB(data: List>, onWikiLinkClick: ((Tag) -> Unit)? = null) { +fun RenderBB(data: List, onWikiLinkClick: ((Tag) -> Unit)? = null) { Column { data.forEach { RenderBB(it, onWikiLinkClick = onWikiLinkClick) @@ -80,7 +80,7 @@ fun RenderBB(data: List>, onWikiLinkClick: ((Tag) -> Unit)? = nul } @Composable -fun RenderBB(data: MessageData<*>, onWikiLinkClick: ((Tag) -> Unit)? = null) { +fun RenderBB(data: MessageData, onWikiLinkClick: ((Tag) -> Unit)? = null) { when (data) { is MessageQuote -> { data.author?.let {