diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt index 854fa87f8..20efa29bf 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt @@ -186,6 +186,7 @@ fun NewPostView( baseReplyTo: Note? = null, quote: Note? = null, fork: Note? = null, + version: Note? = null, enableMessageInterface: Boolean = false, accountViewModel: AccountViewModel, nav: (String) -> Unit, @@ -201,7 +202,7 @@ fun NewPostView( var relayList = remember { accountViewModel.account.activeWriteRelays().toImmutableList() } LaunchedEffect(Unit) { - postViewModel.load(accountViewModel, baseReplyTo, quote, fork) + postViewModel.load(accountViewModel, baseReplyTo, quote, fork, version) launch(Dispatchers.IO) { postViewModel.imageUploadingError.collect { error -> diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostViewModel.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostViewModel.kt index 47838ecd5..510e258be 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostViewModel.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostViewModel.kt @@ -180,6 +180,7 @@ open class NewPostViewModel() : ViewModel() { replyingTo: Note?, quote: Note?, fork: Note?, + version: Note?, ) { this.accountViewModel = accountViewModel this.account = accountViewModel.account @@ -244,7 +245,7 @@ open class NewPostViewModel() : ViewModel() { } fork?.let { - message = TextFieldValue(it.event?.content() ?: "") + message = TextFieldValue(version?.event?.content() ?: it.event?.content() ?: "") urlPreview = findUrlInMessage() it.event?.isSensitive()?.let { diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt index ea6361e6a..9f38ee16e 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt @@ -1025,6 +1025,7 @@ fun InnerNoteWithReactions( nav: (String) -> Unit, ) { val notBoostedNorQuote = !isBoostedNote && !isQuotedNote + val editState = observeEdits(baseNote = baseNote, accountViewModel = accountViewModel) Row( modifier = @@ -1057,6 +1058,7 @@ fun InnerNoteWithReactions( canPreview = canPreview, showSecondRow = showSecondRow, backgroundColor = backgroundColor, + editState = editState, accountViewModel = accountViewModel, nav = nav, ) @@ -1075,6 +1077,7 @@ fun InnerNoteWithReactions( ReactionsRow( baseNote = baseNote, showReactionDetail = notBoostedNorQuote, + editState = editState, accountViewModel = accountViewModel, nav = nav, ) @@ -1151,11 +1154,10 @@ private fun NoteBody( canPreview: Boolean = true, showSecondRow: Boolean, backgroundColor: MutableState, + editState: State>, accountViewModel: AccountViewModel, nav: (String) -> Unit, ) { - val editState = observeEdits(baseNote = baseNote, accountViewModel = accountViewModel) - FirstUserInfoRow( baseNote = baseNote, showAuthorPicture = showAuthorPicture, diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt index 794a20752..64986be17 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt @@ -61,6 +61,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.Immutable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.MutableState +import androidx.compose.runtime.State import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.livedata.observeAsState @@ -99,6 +100,7 @@ import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.service.ZapPaymentHandler import com.vitorpamplona.amethyst.ui.actions.NewPostView +import com.vitorpamplona.amethyst.ui.components.GenericLoadable import com.vitorpamplona.amethyst.ui.components.InLineIconRenderer import com.vitorpamplona.amethyst.ui.navigation.routeToMessage import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel @@ -145,6 +147,7 @@ import kotlin.math.roundToInt fun ReactionsRow( baseNote: Note, showReactionDetail: Boolean, + editState: State>, accountViewModel: AccountViewModel, nav: (String) -> Unit, ) { @@ -152,7 +155,7 @@ fun ReactionsRow( Spacer(modifier = HalfDoubleVertSpacer) - InnerReactionRow(baseNote, showReactionDetail, wantsToSeeReactions, accountViewModel, nav) + InnerReactionRow(baseNote, showReactionDetail, wantsToSeeReactions, editState, accountViewModel, nav) Spacer(modifier = HalfDoubleVertSpacer) @@ -169,6 +172,7 @@ private fun InnerReactionRow( baseNote: Note, showReactionDetail: Boolean, wantsToSeeReactions: MutableState, + editState: State>, accountViewModel: AccountViewModel, nav: (String) -> Unit, ) { @@ -190,6 +194,7 @@ private fun InnerReactionRow( three = { BoostWithDialog( baseNote, + editState, MaterialTheme.colorScheme.placeholderText, accountViewModel, nav, @@ -495,6 +500,7 @@ private fun WatchZapAndRenderGallery( @Composable private fun BoostWithDialog( baseNote: Note, + editState: State>, grayTint: Color, accountViewModel: AccountViewModel, nav: (String) -> Unit, @@ -507,6 +513,7 @@ private fun BoostWithDialog( onClose = { wantsToQuote = null }, baseReplyTo = null, quote = wantsToQuote, + version = (editState.value as? GenericLoadable.Loaded)?.loaded?.modificationToShow?.value, accountViewModel = accountViewModel, nav = nav, ) @@ -528,6 +535,7 @@ private fun BoostWithDialog( onClose = { wantsToFork = null }, baseReplyTo = replyTo, fork = wantsToFork, + version = (editState.value as? GenericLoadable.Loaded)?.loaded?.modificationToShow?.value, accountViewModel = accountViewModel, nav = nav, ) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ThreadFeedView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ThreadFeedView.kt index 4b0c5f7e8..2ff8f03c4 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ThreadFeedView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ThreadFeedView.kt @@ -608,7 +608,7 @@ fun NoteMaster( DisplayZapSplits(noteEvent, false, accountViewModel, nav) } - ReactionsRow(note, true, accountViewModel, nav) + ReactionsRow(note, true, editState, accountViewModel, nav) Divider( thickness = DividerThickness,