removing the state needs for rendering text.
This commit is contained in:
@@ -100,31 +100,26 @@ fun RenderTextEvent(
|
|||||||
note,
|
note,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
) { body ->
|
) { body ->
|
||||||
val eventContent by
|
val eventContent =
|
||||||
remember(note.event) {
|
remember(note.event) {
|
||||||
derivedStateOf {
|
val subject = (note.event as? TextNoteEvent)?.subject()?.ifEmpty { null }
|
||||||
val subject = (note.event as? TextNoteEvent)?.subject()?.ifEmpty { null }
|
val newBody =
|
||||||
val newBody =
|
if (editState.value is GenericLoadable.Loaded) {
|
||||||
if (editState.value is GenericLoadable.Loaded) {
|
val state =
|
||||||
val state =
|
(editState.value as? GenericLoadable.Loaded)?.loaded?.modificationToShow
|
||||||
(editState.value as? GenericLoadable.Loaded)?.loaded?.modificationToShow
|
state?.value?.event?.content() ?: body
|
||||||
state?.value?.event?.content() ?: body
|
|
||||||
} else {
|
|
||||||
body
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!subject.isNullOrBlank() && !newBody.split("\n")[0].contains(subject)) {
|
|
||||||
"### $subject\n$newBody"
|
|
||||||
} else {
|
} else {
|
||||||
newBody
|
body
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!subject.isNullOrBlank() && !newBody.split("\n")[0].contains(subject)) {
|
||||||
|
"### $subject\n$newBody"
|
||||||
|
} else {
|
||||||
|
newBody
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val isAuthorTheLoggedUser =
|
if (makeItShort && accountViewModel.isLoggedUser(note.author)) {
|
||||||
remember(note.event) { accountViewModel.isLoggedUser(note.author) }
|
|
||||||
|
|
||||||
if (makeItShort && isAuthorTheLoggedUser) {
|
|
||||||
Text(
|
Text(
|
||||||
text = eventContent,
|
text = eventContent,
|
||||||
color = MaterialTheme.colorScheme.placeholderText,
|
color = MaterialTheme.colorScheme.placeholderText,
|
||||||
|
|||||||
Reference in New Issue
Block a user