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

View File

@@ -82,7 +82,7 @@ fun TranslatableRichTextViewer(
nav: (String) -> Unit, nav: (String) -> Unit,
) { ) {
var translatedTextState by 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 -> TranslateAndWatchLanguageChanges(content, accountViewModel) { result ->
if ( if (