Passes reply preview to the new Public message screen
This commit is contained in:
@@ -176,8 +176,9 @@ fun AppNavigation(
|
||||
composableFromBottomArgs<Route.NewPublicMessage> {
|
||||
NewPublicMessageScreen(
|
||||
to = it.toKey(),
|
||||
accountViewModel,
|
||||
nav,
|
||||
reply = it.replyId?.let { hex -> accountViewModel.getNoteIfExists(hex) },
|
||||
accountViewModel = accountViewModel,
|
||||
nav = nav,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -201,7 +201,11 @@ fun routeReplyTo(
|
||||
): Route? {
|
||||
val noteEvent = note.event
|
||||
return when (noteEvent) {
|
||||
is PublicMessageEvent -> Route.NewPublicMessage(noteEvent.groupKeySet() - account.userProfile().pubkeyHex)
|
||||
is PublicMessageEvent ->
|
||||
Route.NewPublicMessage(
|
||||
users = noteEvent.groupKeySet() - account.userProfile().pubkeyHex,
|
||||
parentId = noteEvent.id,
|
||||
)
|
||||
is TextNoteEvent -> Route.NewPost(baseReplyTo = note.idHex)
|
||||
is PrivateDmEvent ->
|
||||
routeToMessage(
|
||||
|
||||
@@ -140,9 +140,11 @@ sealed class Route {
|
||||
|
||||
@Serializable data class NewPublicMessage(
|
||||
val to: String,
|
||||
val replyId: HexKey? = null,
|
||||
) : Route() {
|
||||
constructor(users: Set<HexKey>) : this(
|
||||
constructor(users: Set<HexKey>, parentId: HexKey) : this(
|
||||
to = users.joinToString(","),
|
||||
replyId = parentId,
|
||||
)
|
||||
|
||||
fun toKey(): Set<HexKey> = to.split(",").toSet()
|
||||
|
||||
+25
-1
@@ -56,6 +56,7 @@ import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.vitorpamplona.amethyst.R
|
||||
import com.vitorpamplona.amethyst.model.Note
|
||||
import com.vitorpamplona.amethyst.ui.actions.UrlUserTagTransformation
|
||||
import com.vitorpamplona.amethyst.ui.actions.mediaServers.ServerType
|
||||
import com.vitorpamplona.amethyst.ui.actions.uploads.SelectFromGallery
|
||||
@@ -64,6 +65,7 @@ import com.vitorpamplona.amethyst.ui.components.ThinPaddingTextField
|
||||
import com.vitorpamplona.amethyst.ui.navigation.navs.INav
|
||||
import com.vitorpamplona.amethyst.ui.navigation.navs.Nav
|
||||
import com.vitorpamplona.amethyst.ui.navigation.topbars.PostingTopBar
|
||||
import com.vitorpamplona.amethyst.ui.note.NoteCompose
|
||||
import com.vitorpamplona.amethyst.ui.note.creators.contentWarning.ContentSensitivityExplainer
|
||||
import com.vitorpamplona.amethyst.ui.note.creators.contentWarning.MarkAsSensitiveButton
|
||||
import com.vitorpamplona.amethyst.ui.note.creators.emojiSuggestions.ShowEmojiSuggestionList
|
||||
@@ -89,6 +91,7 @@ import com.vitorpamplona.amethyst.ui.theme.DividerThickness
|
||||
import com.vitorpamplona.amethyst.ui.theme.Font14SP
|
||||
import com.vitorpamplona.amethyst.ui.theme.Size10dp
|
||||
import com.vitorpamplona.amethyst.ui.theme.Size5dp
|
||||
import com.vitorpamplona.amethyst.ui.theme.imageModifier
|
||||
import com.vitorpamplona.amethyst.ui.theme.placeholderText
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -101,6 +104,7 @@ import kotlinx.coroutines.withContext
|
||||
@Composable
|
||||
fun NewPublicMessageScreen(
|
||||
to: Set<HexKey>? = null,
|
||||
reply: Note? = null,
|
||||
accountViewModel: AccountViewModel,
|
||||
nav: Nav,
|
||||
) {
|
||||
@@ -112,6 +116,9 @@ fun NewPublicMessageScreen(
|
||||
to?.let {
|
||||
postViewModel.load(it)
|
||||
}
|
||||
reply?.let {
|
||||
postViewModel.reply(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +178,24 @@ fun PublicMessageScreenContent(
|
||||
Modifier.fillMaxWidth().verticalScroll(scrollState),
|
||||
verticalArrangement = spacedBy(Size10dp),
|
||||
) {
|
||||
SendDirectMessageTo(postViewModel, accountViewModel)
|
||||
val replyTo = postViewModel.replyingTo
|
||||
|
||||
if (replyTo == null) {
|
||||
SendDirectMessageTo(postViewModel, accountViewModel)
|
||||
} else {
|
||||
Row {
|
||||
NoteCompose(
|
||||
baseNote = replyTo,
|
||||
modifier = MaterialTheme.colorScheme.imageModifier,
|
||||
isQuotedNote = true,
|
||||
unPackReply = false,
|
||||
makeItShort = true,
|
||||
quotesLeft = 1,
|
||||
accountViewModel = accountViewModel,
|
||||
nav = nav,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
MessageFieldRow(postViewModel, accountViewModel, postViewModel.toUsers.text.isNotBlank())
|
||||
|
||||
|
||||
+7
-1
@@ -133,6 +133,8 @@ class NewPublicMessageViewModel :
|
||||
}
|
||||
}
|
||||
|
||||
var replyingTo: Note? by mutableStateOf(null)
|
||||
|
||||
val iMetaAttachments = IMetaAttachments()
|
||||
var nip95attachments by mutableStateOf<List<Pair<FileStorageEvent, FileStorageHeaderEvent>>>(emptyList())
|
||||
|
||||
@@ -203,6 +205,10 @@ class NewPublicMessageViewModel :
|
||||
)
|
||||
}
|
||||
|
||||
fun reply(post: Note) {
|
||||
this.replyingTo = post
|
||||
}
|
||||
|
||||
fun quote(quote: Note) {
|
||||
message = TextFieldValue(message.text + "\nnostr:${quote.toNEvent()}")
|
||||
urlPreviews.update(message)
|
||||
@@ -332,7 +338,7 @@ class NewPublicMessageViewModel :
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun createTemplate(): EventTemplate<out Event>? {
|
||||
private suspend fun createTemplate(): EventTemplate<PublicMessageEvent>? {
|
||||
val toUsersTagger = NewMessageTagger(this@NewPublicMessageViewModel.toUsers.text, null, null, accountViewModel)
|
||||
toUsersTagger.run()
|
||||
|
||||
|
||||
@@ -120,6 +120,7 @@ val HalfStartPadding = Modifier.padding(start = 5.dp)
|
||||
val StdStartPadding = Modifier.padding(start = 10.dp)
|
||||
val StdTopPadding = Modifier.padding(top = 10.dp)
|
||||
val HalfTopPadding = Modifier.padding(top = 5.dp)
|
||||
val HalfHalfTopPadding = Modifier.padding(top = 3.dp)
|
||||
|
||||
val HalfHalfVertPadding = Modifier.padding(vertical = 3.dp)
|
||||
val HalfHalfHorzModifier = Modifier.padding(horizontal = 3.dp)
|
||||
|
||||
Reference in New Issue
Block a user