Skip to content

Commit

Permalink
fix home topic media
Browse files Browse the repository at this point in the history
  • Loading branch information
storytellerF committed Dec 26, 2024
1 parent 7fca344 commit e4cdfa8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 -> {
Expand All @@ -130,7 +129,6 @@ private fun TopicContentFieldInternal(
topicInfo: TopicInfo,
rawMediaList: List<MediaInfo>,
plain1: String,
showHeadline: Boolean,
onClick: (() -> Unit)?
) {
val mediaList = if (isPrivate) {
Expand All @@ -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()
},
Expand Down

0 comments on commit e4cdfa8

Please sign in to comment.