Render quoted note

This commit is contained in:
Kgothatso Ngako
2026-05-01 18:26:09 +02:00
parent f1011c0ae8
commit 54f6a0ee26
6 changed files with 39 additions and 37 deletions

View File

@@ -42,21 +42,22 @@ data class LocalNostrEvent(
val repostedRelation: RepostedRelation? = null,
@Relation(
entity = QuotedRelation::class,
parentColumn = "id",
entityColumn = "quotingNostrEventId"
)
val quotedRelation: QuotedRelation? = null,
val localQuotedNostrEvent: LocalQuotedNostrEvent? = null,
@Relation(
parentColumn = "id",
entityColumn = "id",
associateBy = Junction(
value = QuotedRelation::class,
parentColumn = "quotingNostrEventId",
entityColumn = "quotedNostrEventId"
)
)
val quotedNostrEvent: NostrEvent? = null,
// @Relation(
// parentColumn = "id",
// entityColumn = "id",
// associateBy = Junction(
// value = QuotedRelation::class,
// parentColumn = "quotingNostrEventId",
// entityColumn = "quotedNostrEventId"
// )
// )
// val quotedNostrEvent: NostrEvent? = null,
@Relation(
parentColumn = "id",

View File

@@ -1,11 +1,8 @@
package ac.cord.auxiliary.compose.database.model.intermdiate
import ac.cord.auxiliary.compose.database.model.InReplyToRelation
import ac.cord.auxiliary.compose.database.model.Mention
import ac.cord.auxiliary.compose.database.model.NostrEvent
import ac.cord.auxiliary.compose.database.model.Profile
import ac.cord.auxiliary.compose.database.model.QuotedRelation
import ac.cord.auxiliary.compose.database.model.RepostedRelation
import ac.cord.auxiliary.compose.extensions.toFormattedTimeAndDateString
import ac.cord.auxiliary.compose.ui.composable.widgets.profile.ProfileAvatar
import androidx.compose.foundation.layout.Arrangement
@@ -22,24 +19,29 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.room.Embedded
import androidx.room.Junction
import androidx.room.Relation
data class LocalQuotedNostrEvent(
@Embedded val nostrEvent: NostrEvent,
@Embedded val quotedRelation: QuotedRelation,
@Relation(
parentColumn = "pubKey",
parentColumn = "quotedNostrEventId",
entityColumn = "id"
)
val nostrEvent: NostrEvent,
@Relation(
parentColumn = "quotedProfilePublicKey",
entityColumn = "publicKey"
)
val profile: Profile?,
@Relation(
entity = Mention::class,
parentColumn = "id",
entityColumn = "nostrEventId",
)
val mentionedProfiles: List<LocalMention?> = emptyList(),
// @Relation(
// entity = Mention::class,
// parentColumn = "id",
// entityColumn = "nostrEventId",
// )
// val mentionedProfiles: List<LocalMention?> = emptyList(),
) {
@Composable
fun RenderNotePreview() {
@@ -72,6 +74,8 @@ data class LocalQuotedNostrEvent(
}
}
}
// TODO: Use RichContent...
Text(
modifier = Modifier.fillMaxWidth().padding(
horizontal = 20.dp

View File

@@ -40,9 +40,9 @@ internal fun QuotedAddressableNote(
// }
// }
if (localNostrEvent?.quotedRelation != null) {
if (localNostrEvent?.localQuotedNostrEvent != null) {
QuotedNote(
quotedNostrEvent = localNostrEvent.quotedRelation,
localQuotedNostrEvent = localNostrEvent.localQuotedNostrEvent,
onNoteClick = onNoteClick,
noteActions = noteActions
)

View File

@@ -1,8 +1,8 @@
package ac.cord.auxiliary.compose.ui.composable.widgets.content
import ac.cord.auxiliary.compose.database.model.NostrEvent
import ac.cord.auxiliary.compose.database.model.Profile
import ac.cord.auxiliary.compose.database.model.QuotedRelation
import ac.cord.auxiliary.compose.database.model.intermdiate.LocalQuotedNostrEvent
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Row
@@ -23,7 +23,7 @@ import androidx.compose.ui.unit.dp
@Composable
fun QuotedNote(
quotedNostrEvent: QuotedRelation? = null,
localQuotedNostrEvent: LocalQuotedNostrEvent? = null,
quotedProfile: Profile? = null,
relayHints: List<String> = emptyList(),
onNoteClick: ((String) -> Unit)? = null,
@@ -50,7 +50,7 @@ fun QuotedNote(
// }
// }
if (quotedNostrEvent != null && noteActions != null) {
if (localQuotedNostrEvent != null && noteActions != null) {
// Full rendering with all interactive features
Surface(
@@ -61,10 +61,10 @@ fun QuotedNote(
.fillMaxWidth()
.padding(vertical = 6.dp)
) {
Text("Quote render coming soon")
localQuotedNostrEvent.RenderNotePreview()
// quotedNostrEvent.RenderNotePreview()
}
} else if (quotedNostrEvent != null) {
} else if (localQuotedNostrEvent != null) {
// Simple fallback rendering (no noteActions available)
Surface(
shape = RoundedCornerShape(12.dp),
@@ -74,12 +74,11 @@ fun QuotedNote(
.fillMaxWidth()
.padding(vertical = 6.dp)
.then(
if (effectiveNoteClick != null) Modifier.clickable { effectiveNoteClick(quotedNostrEvent.quotedNostrEventId) }
if (effectiveNoteClick != null) Modifier.clickable { effectiveNoteClick(localQuotedNostrEvent.nostrEvent.id) }
else Modifier
)
) {
Text("Quote render coming soon")
// quotedPost.RenderNotePreview()
localQuotedNostrEvent.RenderNotePreview()
}
} else {
// Loading state

View File

@@ -275,9 +275,9 @@ fun RichContent(
LinkPreview(url = segment.url)
}
is ContentSegment.NostrNoteSegment -> {
if (localNostrEvent.quotedRelation != null) {
if (localNostrEvent.localQuotedNostrEvent != null) {
QuotedNote(
quotedNostrEvent = localNostrEvent.quotedRelation,
localQuotedNostrEvent = localNostrEvent.localQuotedNostrEvent,
relayHints = segment.relayHints,
onNoteClick = onNoteClick,
noteActions = noteActions

View File

@@ -1,2 +0,0 @@
package ac.cord.auxiliary.compose.ui.composable.widgets.feed