Making forks work with revisions.

This commit is contained in:
Vitor Pamplona
2024-03-01 15:39:24 -05:00
parent af784a5bda
commit bc7a578cfe
5 changed files with 18 additions and 6 deletions
@@ -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 ->
@@ -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 {
@@ -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<Color>,
editState: State<GenericLoadable<EditState>>,
accountViewModel: AccountViewModel,
nav: (String) -> Unit,
) {
val editState = observeEdits(baseNote = baseNote, accountViewModel = accountViewModel)
FirstUserInfoRow(
baseNote = baseNote,
showAuthorPicture = showAuthorPicture,
@@ -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<GenericLoadable<EditState>>,
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<Boolean>,
editState: State<GenericLoadable<EditState>>,
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<GenericLoadable<EditState>>,
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,
)
@@ -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,