Fixes unable to see original post when clicking on the edit button

This commit is contained in:
Vitor Pamplona 2024-07-01 11:47:30 -04:00
parent 5c21e219fe
commit 236de87574
2 changed files with 26 additions and 18 deletions

View File

@ -100,23 +100,24 @@ fun RenderTextEvent(
note,
accountViewModel,
) { body ->
val eventContent =
remember(note.event) {
val subject = (note.event as? TextNoteEvent)?.subject()?.ifEmpty { null }
val newBody =
if (editState.value is GenericLoadable.Loaded) {
val state =
(editState.value as? GenericLoadable.Loaded)?.loaded?.modificationToShow
state?.value?.event?.content() ?: body
} else {
body
}
val subject = (note.event as? TextNoteEvent)?.subject()?.ifEmpty { null }
val newBody =
if (editState.value is GenericLoadable.Loaded) {
(editState.value as? GenericLoadable.Loaded)
?.loaded
?.modificationToShow
?.value
?.event
?.content() ?: body
} else {
body
}
if (!subject.isNullOrBlank() && !newBody.split("\n")[0].contains(subject)) {
"### $subject\n$newBody"
} else {
newBody
}
val eventContent =
if (!subject.isNullOrBlank() && !newBody.split("\n")[0].startsWith(subject)) {
"### $subject\n$newBody"
} else {
newBody
}
if (makeItShort && accountViewModel.isLoggedUser(note.author)) {
@ -141,7 +142,14 @@ fun RenderTextEvent(
modifier = Modifier.fillMaxWidth(),
tags = tags,
backgroundColor = backgroundColor,
id = note.idHex,
id =
if (editState.value is GenericLoadable.Loaded) {
(editState.value as GenericLoadable.Loaded<EditState>)
.loaded.modificationToShow.value
?.idHex ?: note.idHex
} else {
note.idHex
},
callbackUri = note.toNostrUri(),
accountViewModel = accountViewModel,
nav = nav,

View File

@ -82,7 +82,7 @@ fun TranslatableRichTextViewer(
nav: (String) -> Unit,
) {
var translatedTextState by
remember(id, content.length) { mutableStateOf(TranslationConfig(content, null, null, false)) }
remember(id) { mutableStateOf(TranslationConfig(content, null, null, false)) }
TranslateAndWatchLanguageChanges(content, accountViewModel) { result ->
if (