Making forks work with revisions.
This commit is contained in:
@@ -186,6 +186,7 @@ fun NewPostView(
|
|||||||
baseReplyTo: Note? = null,
|
baseReplyTo: Note? = null,
|
||||||
quote: Note? = null,
|
quote: Note? = null,
|
||||||
fork: Note? = null,
|
fork: Note? = null,
|
||||||
|
version: Note? = null,
|
||||||
enableMessageInterface: Boolean = false,
|
enableMessageInterface: Boolean = false,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit,
|
nav: (String) -> Unit,
|
||||||
@@ -201,7 +202,7 @@ fun NewPostView(
|
|||||||
var relayList = remember { accountViewModel.account.activeWriteRelays().toImmutableList() }
|
var relayList = remember { accountViewModel.account.activeWriteRelays().toImmutableList() }
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
postViewModel.load(accountViewModel, baseReplyTo, quote, fork)
|
postViewModel.load(accountViewModel, baseReplyTo, quote, fork, version)
|
||||||
|
|
||||||
launch(Dispatchers.IO) {
|
launch(Dispatchers.IO) {
|
||||||
postViewModel.imageUploadingError.collect { error ->
|
postViewModel.imageUploadingError.collect { error ->
|
||||||
|
|||||||
@@ -180,6 +180,7 @@ open class NewPostViewModel() : ViewModel() {
|
|||||||
replyingTo: Note?,
|
replyingTo: Note?,
|
||||||
quote: Note?,
|
quote: Note?,
|
||||||
fork: Note?,
|
fork: Note?,
|
||||||
|
version: Note?,
|
||||||
) {
|
) {
|
||||||
this.accountViewModel = accountViewModel
|
this.accountViewModel = accountViewModel
|
||||||
this.account = accountViewModel.account
|
this.account = accountViewModel.account
|
||||||
@@ -244,7 +245,7 @@ open class NewPostViewModel() : ViewModel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fork?.let {
|
fork?.let {
|
||||||
message = TextFieldValue(it.event?.content() ?: "")
|
message = TextFieldValue(version?.event?.content() ?: it.event?.content() ?: "")
|
||||||
urlPreview = findUrlInMessage()
|
urlPreview = findUrlInMessage()
|
||||||
|
|
||||||
it.event?.isSensitive()?.let {
|
it.event?.isSensitive()?.let {
|
||||||
|
|||||||
@@ -1025,6 +1025,7 @@ fun InnerNoteWithReactions(
|
|||||||
nav: (String) -> Unit,
|
nav: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
val notBoostedNorQuote = !isBoostedNote && !isQuotedNote
|
val notBoostedNorQuote = !isBoostedNote && !isQuotedNote
|
||||||
|
val editState = observeEdits(baseNote = baseNote, accountViewModel = accountViewModel)
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier =
|
modifier =
|
||||||
@@ -1057,6 +1058,7 @@ fun InnerNoteWithReactions(
|
|||||||
canPreview = canPreview,
|
canPreview = canPreview,
|
||||||
showSecondRow = showSecondRow,
|
showSecondRow = showSecondRow,
|
||||||
backgroundColor = backgroundColor,
|
backgroundColor = backgroundColor,
|
||||||
|
editState = editState,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
@@ -1075,6 +1077,7 @@ fun InnerNoteWithReactions(
|
|||||||
ReactionsRow(
|
ReactionsRow(
|
||||||
baseNote = baseNote,
|
baseNote = baseNote,
|
||||||
showReactionDetail = notBoostedNorQuote,
|
showReactionDetail = notBoostedNorQuote,
|
||||||
|
editState = editState,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
@@ -1151,11 +1154,10 @@ private fun NoteBody(
|
|||||||
canPreview: Boolean = true,
|
canPreview: Boolean = true,
|
||||||
showSecondRow: Boolean,
|
showSecondRow: Boolean,
|
||||||
backgroundColor: MutableState<Color>,
|
backgroundColor: MutableState<Color>,
|
||||||
|
editState: State<GenericLoadable<EditState>>,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit,
|
nav: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
val editState = observeEdits(baseNote = baseNote, accountViewModel = accountViewModel)
|
|
||||||
|
|
||||||
FirstUserInfoRow(
|
FirstUserInfoRow(
|
||||||
baseNote = baseNote,
|
baseNote = baseNote,
|
||||||
showAuthorPicture = showAuthorPicture,
|
showAuthorPicture = showAuthorPicture,
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.runtime.Immutable
|
import androidx.compose.runtime.Immutable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.MutableState
|
import androidx.compose.runtime.MutableState
|
||||||
|
import androidx.compose.runtime.State
|
||||||
import androidx.compose.runtime.derivedStateOf
|
import androidx.compose.runtime.derivedStateOf
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.livedata.observeAsState
|
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.model.Note
|
||||||
import com.vitorpamplona.amethyst.service.ZapPaymentHandler
|
import com.vitorpamplona.amethyst.service.ZapPaymentHandler
|
||||||
import com.vitorpamplona.amethyst.ui.actions.NewPostView
|
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.components.InLineIconRenderer
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.routeToMessage
|
import com.vitorpamplona.amethyst.ui.navigation.routeToMessage
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
@@ -145,6 +147,7 @@ import kotlin.math.roundToInt
|
|||||||
fun ReactionsRow(
|
fun ReactionsRow(
|
||||||
baseNote: Note,
|
baseNote: Note,
|
||||||
showReactionDetail: Boolean,
|
showReactionDetail: Boolean,
|
||||||
|
editState: State<GenericLoadable<EditState>>,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit,
|
nav: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
@@ -152,7 +155,7 @@ fun ReactionsRow(
|
|||||||
|
|
||||||
Spacer(modifier = HalfDoubleVertSpacer)
|
Spacer(modifier = HalfDoubleVertSpacer)
|
||||||
|
|
||||||
InnerReactionRow(baseNote, showReactionDetail, wantsToSeeReactions, accountViewModel, nav)
|
InnerReactionRow(baseNote, showReactionDetail, wantsToSeeReactions, editState, accountViewModel, nav)
|
||||||
|
|
||||||
Spacer(modifier = HalfDoubleVertSpacer)
|
Spacer(modifier = HalfDoubleVertSpacer)
|
||||||
|
|
||||||
@@ -169,6 +172,7 @@ private fun InnerReactionRow(
|
|||||||
baseNote: Note,
|
baseNote: Note,
|
||||||
showReactionDetail: Boolean,
|
showReactionDetail: Boolean,
|
||||||
wantsToSeeReactions: MutableState<Boolean>,
|
wantsToSeeReactions: MutableState<Boolean>,
|
||||||
|
editState: State<GenericLoadable<EditState>>,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit,
|
nav: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
@@ -190,6 +194,7 @@ private fun InnerReactionRow(
|
|||||||
three = {
|
three = {
|
||||||
BoostWithDialog(
|
BoostWithDialog(
|
||||||
baseNote,
|
baseNote,
|
||||||
|
editState,
|
||||||
MaterialTheme.colorScheme.placeholderText,
|
MaterialTheme.colorScheme.placeholderText,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
nav,
|
nav,
|
||||||
@@ -495,6 +500,7 @@ private fun WatchZapAndRenderGallery(
|
|||||||
@Composable
|
@Composable
|
||||||
private fun BoostWithDialog(
|
private fun BoostWithDialog(
|
||||||
baseNote: Note,
|
baseNote: Note,
|
||||||
|
editState: State<GenericLoadable<EditState>>,
|
||||||
grayTint: Color,
|
grayTint: Color,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit,
|
nav: (String) -> Unit,
|
||||||
@@ -507,6 +513,7 @@ private fun BoostWithDialog(
|
|||||||
onClose = { wantsToQuote = null },
|
onClose = { wantsToQuote = null },
|
||||||
baseReplyTo = null,
|
baseReplyTo = null,
|
||||||
quote = wantsToQuote,
|
quote = wantsToQuote,
|
||||||
|
version = (editState.value as? GenericLoadable.Loaded)?.loaded?.modificationToShow?.value,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
@@ -528,6 +535,7 @@ private fun BoostWithDialog(
|
|||||||
onClose = { wantsToFork = null },
|
onClose = { wantsToFork = null },
|
||||||
baseReplyTo = replyTo,
|
baseReplyTo = replyTo,
|
||||||
fork = wantsToFork,
|
fork = wantsToFork,
|
||||||
|
version = (editState.value as? GenericLoadable.Loaded)?.loaded?.modificationToShow?.value,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -608,7 +608,7 @@ fun NoteMaster(
|
|||||||
DisplayZapSplits(noteEvent, false, accountViewModel, nav)
|
DisplayZapSplits(noteEvent, false, accountViewModel, nav)
|
||||||
}
|
}
|
||||||
|
|
||||||
ReactionsRow(note, true, accountViewModel, nav)
|
ReactionsRow(note, true, editState, accountViewModel, nav)
|
||||||
|
|
||||||
Divider(
|
Divider(
|
||||||
thickness = DividerThickness,
|
thickness = DividerThickness,
|
||||||
|
|||||||
Reference in New Issue
Block a user