From e4cdfa8d986fc7664b6c26875f7293d9fc592171 Mon Sep 17 00:00:00 2001 From: storytellerF <34095089+storytellerF@users.noreply.github.com> Date: Thu, 26 Dec 2024 23:35:11 +0800 Subject: [PATCH] fix home topic media --- .../com/storyteller_f/a/app/model/Models.kt | 2 +- .../com/storyteller_f/a/app/topic/TopicCell.kt | 15 +++------------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/com/storyteller_f/a/app/model/Models.kt b/composeApp/src/commonMain/kotlin/com/storyteller_f/a/app/model/Models.kt index d6ec2fb..479b119 100644 --- a/composeApp/src/commonMain/kotlin/com/storyteller_f/a/app/model/Models.kt +++ b/composeApp/src/commonMain/kotlin/com/storyteller_f/a/app/model/Models.kt @@ -153,7 +153,7 @@ class TopicsViewModel(id: PrimaryKey, val type: ObjectType? = null) : PagingView private fun extractHeadlineIfPlain(it: TopicInfo): TopicInfo { val content = it.content return if (content is TopicContent.Plain) { - it.copy(content = TopicContent.Extracted(extractMarkdownHeadline(content.plain))) + it.copy(content = TopicContent.Extracted(extractMarkdownHeadline(content.plain), content.list)) } else { it } diff --git a/composeApp/src/commonMain/kotlin/com/storyteller_f/a/app/topic/TopicCell.kt b/composeApp/src/commonMain/kotlin/com/storyteller_f/a/app/topic/TopicCell.kt index a786d1a..3476e1f 100644 --- a/composeApp/src/commonMain/kotlin/com/storyteller_f/a/app/topic/TopicCell.kt +++ b/composeApp/src/commonMain/kotlin/com/storyteller_f/a/app/topic/TopicCell.kt @@ -27,7 +27,6 @@ import com.storyteller_f.shared.model.MediaInfo import com.storyteller_f.shared.model.TopicContent import com.storyteller_f.shared.model.TopicInfo import com.storyteller_f.shared.model.UserInfo -import com.storyteller_f.shared.utils.extractMarkdownHeadline import org.jetbrains.compose.resources.stringResource @OptIn(ExperimentalMaterial3Api::class) @@ -103,14 +102,14 @@ fun TopicContentField( val isPrivate = topicInfo.isPrivate val rawMediaList = content.list val plain1 = content.plain - TopicContentFieldInternal(isPrivate, topicInfo, rawMediaList, plain1, showHeadline, onClick) + TopicContentFieldInternal(isPrivate, topicInfo, rawMediaList, plain1, onClick) } is TopicContent.Extracted -> { val isPrivate = topicInfo.isPrivate val rawMediaList = content.list val plain1 = content.plain - TopicContentFieldInternal(isPrivate, topicInfo, rawMediaList, plain1, showHeadline, onClick) + TopicContentFieldInternal(isPrivate, topicInfo, rawMediaList, plain1, onClick) } is TopicContent.DecryptFailed, is TopicContent.Encrypted -> { @@ -130,7 +129,6 @@ private fun TopicContentFieldInternal( topicInfo: TopicInfo, rawMediaList: List, plain1: String, - showHeadline: Boolean, onClick: (() -> Unit)? ) { val mediaList = if (isPrivate) { @@ -140,16 +138,9 @@ private fun TopicContentFieldInternal( } else { rawMediaList } - val plain by produceState("", plain1, showHeadline) { - value = if (showHeadline) { - extractMarkdownHeadline(plain1) - } else { - plain1 - } - } val mediaMap = mediaList.associateBy { it.item.name } Markdown( - plain, + plain1, modifier = Modifier.fillMaxWidth().clickable(onClick != null) { onClick?.invoke() },