Showing mentioned profiles
This commit is contained in:
@@ -5,13 +5,16 @@ import ac.cord.auxiliary.compose.database.model.Post
|
||||
import ac.cord.auxiliary.compose.database.model.intermdiate.LocalPost
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy.Companion.IGNORE
|
||||
import androidx.room.Query
|
||||
import androidx.room.Upsert
|
||||
|
||||
@Dao
|
||||
interface MentionDao {
|
||||
|
||||
@Insert
|
||||
@Insert(
|
||||
onConflict = IGNORE
|
||||
)
|
||||
suspend fun insert(mention: Mention)
|
||||
|
||||
@Upsert
|
||||
|
||||
@@ -4,6 +4,7 @@ import ac.cord.auxiliary.compose.database.AuxDatabase
|
||||
import ac.cord.auxiliary.compose.database.GENESIS_AT
|
||||
import ac.cord.auxiliary.compose.database.model.BroadcastNostrEventRequest
|
||||
import ac.cord.auxiliary.compose.database.model.Connection
|
||||
import ac.cord.auxiliary.compose.database.model.Mention
|
||||
import ac.cord.auxiliary.compose.database.model.NostrEvent
|
||||
import ac.cord.auxiliary.compose.database.model.Post
|
||||
import ac.cord.auxiliary.compose.database.model.Profile
|
||||
@@ -148,6 +149,7 @@ abstract class NostrDao(
|
||||
|
||||
if (profile == null) {
|
||||
val placeHolderProfile = Profile(
|
||||
displayName = "LOADING PROFILE...",
|
||||
publicKey = nostrEvent.pubKey,
|
||||
createdAt = GENESIS_AT,
|
||||
nostrEventId = nostrEvent.id, // Will get overwriting by sync,
|
||||
@@ -335,6 +337,7 @@ abstract class NostrDao(
|
||||
// Save a placeholder
|
||||
database.profileDao().insertPlaceholderProfile(
|
||||
Profile(
|
||||
displayName = "LOADING PROFILE...",
|
||||
publicKey = taggedUser.pubKey,
|
||||
createdAt = GENESIS_AT,
|
||||
nostrEventId = nostrEvent.id, // Will get overwriting by sync,
|
||||
@@ -342,6 +345,13 @@ abstract class NostrDao(
|
||||
)
|
||||
}
|
||||
|
||||
database.mentionDao().insert(
|
||||
Mention(
|
||||
mentionedPublicKey = taggedUser.pubKey,
|
||||
nostrEventId = nostrEvent.id,
|
||||
relayUrl = taggedUser.relayHint?.url
|
||||
)
|
||||
)
|
||||
val synchronizeNostrEventRequests = if (recommendedRelay != null) {
|
||||
// listOf(
|
||||
// SynchronizeNostrEventRequest(
|
||||
@@ -465,6 +475,7 @@ abstract class NostrDao(
|
||||
if (quotedProfilePublicKey != null && quotedProfile == null) {
|
||||
database.profileDao().insertPlaceholderProfile(
|
||||
Profile(
|
||||
displayName = "LOADING PROFILE...",
|
||||
publicKey = quotedProfilePublicKey,
|
||||
createdAt = GENESIS_AT,
|
||||
nostrEventId = nostrEvent.id, // Will get overwriting by sync,
|
||||
@@ -509,6 +520,7 @@ abstract class NostrDao(
|
||||
if (repostedProfilePublicKey != null && repostedProfile == null) {
|
||||
database.profileDao().insertPlaceholderProfile(
|
||||
Profile(
|
||||
displayName = "LOADING PROFILE...",
|
||||
publicKey = repostedProfilePublicKey,
|
||||
createdAt = GENESIS_AT,
|
||||
nostrEventId = nostrEvent.id, // Will get overwriting by sync,
|
||||
@@ -562,6 +574,7 @@ abstract class NostrDao(
|
||||
if (inReplyToRootProfilePublicKey != null && inReplyToProfile == null) {
|
||||
database.profileDao().insertPlaceholderProfile(
|
||||
Profile(
|
||||
displayName = "LOADING PROFILE...",
|
||||
publicKey = inReplyToRootProfilePublicKey,
|
||||
createdAt = GENESIS_AT,
|
||||
nostrEventId = nostrEvent.id, // Will get overwriting by sync,
|
||||
@@ -633,6 +646,7 @@ abstract class NostrDao(
|
||||
|
||||
if (profile == null) {
|
||||
val placeHolderProfile = Profile(
|
||||
displayName = "LOADING PROFILE...",
|
||||
publicKey = followedHexKEys,
|
||||
createdAt = GENESIS_AT,
|
||||
nostrEventId = nostrEvent.id, // Will get overwriting by sync,
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package ac.cord.auxiliary.compose.database.model.intermdiate
|
||||
|
||||
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 androidx.room.Embedded
|
||||
import androidx.room.Relation
|
||||
|
||||
data class LocalMention(
|
||||
@Embedded val mention: Mention,
|
||||
|
||||
@Relation(
|
||||
parentColumn = "mentionedPublicKey",
|
||||
entityColumn = "publicKey"
|
||||
)
|
||||
val profile: Profile?,
|
||||
)
|
||||
@@ -75,21 +75,12 @@ data class LocalNostrEvent(
|
||||
)
|
||||
val inReplyToNostrEvent: InReplyToRelation? = null,
|
||||
|
||||
// @Relation(
|
||||
// parentColumn = "id",
|
||||
// entityColumn = "nostrEventId",
|
||||
// associateBy = Junction(
|
||||
// value = Mention::class,
|
||||
// parentColumn = "mentionedPublicKey",
|
||||
// entityColumn = "mentionedPublicKey"
|
||||
// )
|
||||
// )
|
||||
// val mentionedProfiles: List<Profile> = emptyList()
|
||||
@Relation(
|
||||
entity = Mention::class,
|
||||
parentColumn = "id",
|
||||
entityColumn = "nostrEventId",
|
||||
)
|
||||
val mentions: List<Mention> = emptyList()
|
||||
val mentionedProfiles: List<LocalMention> = emptyList(),
|
||||
) {
|
||||
@Composable
|
||||
fun RenderNotePreview() {
|
||||
|
||||
@@ -209,10 +209,10 @@ private fun TextNoteFeedItem(
|
||||
SuggestionChip(
|
||||
label = {
|
||||
Text(
|
||||
text = if (localNostrEvent.mentions.isNotEmpty()) {
|
||||
localNostrEvent.mentions.joinToString(",") { it.mentionedPublicKey }
|
||||
text = if (localNostrEvent.mentionedProfiles.isNotEmpty()) {
|
||||
localNostrEvent.mentionedProfiles.joinToString(",") { it.profile?.humanReadableNameOrPubkey() ?: "Find user information" }
|
||||
} else {
|
||||
":-|"
|
||||
":-("
|
||||
}
|
||||
)
|
||||
},
|
||||
@@ -220,9 +220,8 @@ private fun TextNoteFeedItem(
|
||||
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
|
||||
items(
|
||||
items = nostrEvent.tags,
|
||||
) { tag ->
|
||||
|
||||
Reference in New Issue
Block a user