Crashing bug has been fixed
This commit is contained in:
@@ -8,6 +8,7 @@ import androidx.room3.OnConflictStrategy.Companion.IGNORE
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.RawQuery
|
||||
import androidx.room3.RoomRawQuery
|
||||
import androidx.room3.Transaction
|
||||
import androidx.room3.Upsert
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Kind
|
||||
@@ -16,33 +17,39 @@ import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
interface NostrEventDao {
|
||||
@Transaction
|
||||
@Query("SELECT * FROM NostrEvent WHERE kind in (:kinds) ORDER BY createdAt DESC")
|
||||
fun observeNostrEvents(kinds: Array<Kind>): Flow<List<LocalNostrEvent>?>
|
||||
|
||||
@Transaction
|
||||
@Query("SELECT * FROM NostrEvent WHERE content LIKE '%' || :search || '%' AND kind in (:kinds) ORDER BY createdAt DESC")
|
||||
fun observeFilteredNostrEvents(
|
||||
kinds: Array<Kind>,
|
||||
search: String
|
||||
): Flow<List<LocalNostrEvent>?>
|
||||
|
||||
@Transaction
|
||||
@Query("SELECT * FROM NostrEvent WHERE kind in (:kinds) AND id in (:ids) ORDER BY createdAt DESC")
|
||||
fun observeFilteredNostrEvents(
|
||||
kinds: Array<Kind>,
|
||||
ids: Array<HexKey>,
|
||||
): Flow<List<LocalNostrEvent>?>
|
||||
|
||||
@Transaction
|
||||
@Query("SELECT * FROM NostrEvent WHERE kind in (:kinds) AND pubKey in (:authors) ORDER BY createdAt DESC LIMIT 50")
|
||||
fun observeAuthoredNostrEvents(
|
||||
kinds: Array<Kind>,
|
||||
authors: Array<HexKey>,
|
||||
): Flow<List<LocalNostrEvent>?>
|
||||
|
||||
@Transaction
|
||||
@Query("SELECT * FROM NostrEvent WHERE tags LIKE '%' || :publicKey || '%' AND kind in (:kinds) ORDER BY createdAt DESC")
|
||||
fun observePublicKeyMentionedNostrEvents(
|
||||
kinds: Array<Kind>,
|
||||
publicKey: HexKey
|
||||
): Flow<List<LocalNostrEvent>?>
|
||||
|
||||
@Transaction
|
||||
@RawQuery
|
||||
fun observePublicKeyFollowingNostrEvents(
|
||||
query: RoomRawQuery
|
||||
@@ -51,6 +58,7 @@ interface NostrEventDao {
|
||||
@Query("SELECT * FROM NostrEvent WHERE kind in (:kinds) ORDER BY savedAt DESC")
|
||||
fun getAllNostrEvents(kinds: Array<Kind>): List<NostrEvent>
|
||||
|
||||
@Transaction
|
||||
@Query("SELECT * FROM NostrEvent WHERE id = :id")
|
||||
fun observeNostrEventById(id: String): Flow<LocalNostrEvent?>
|
||||
|
||||
|
||||
@@ -56,11 +56,12 @@ data class LocalNostrEvent(
|
||||
)
|
||||
val localInReplyToNostrEvent: LocalInReplyToNostrEvent? = null,
|
||||
|
||||
// @Relation(
|
||||
// parentColumn = "id",
|
||||
// entityColumn = "mentioningNostrEventId",
|
||||
// )
|
||||
// val mentionedProfiles: List<Mention>? = emptyList(),
|
||||
@Relation(
|
||||
entity = Mention::class,
|
||||
parentColumn = "id",
|
||||
entityColumn = "mentioningNostrEventId",
|
||||
)
|
||||
val mentionedProfiles: List<LocalMention>? = emptyList(),
|
||||
) {
|
||||
@Composable
|
||||
fun RenderNotePreview() {
|
||||
|
||||
@@ -37,6 +37,13 @@ data class LocalQuotedNostrEvent(
|
||||
entityColumn = "publicKey"
|
||||
)
|
||||
val profile: Profile?,
|
||||
|
||||
@Relation(
|
||||
entity = Mention::class,
|
||||
parentColumn = "quotedNostrEventId",
|
||||
entityColumn = "mentioningNostrEventId",
|
||||
)
|
||||
val mentionedProfiles: List<LocalMention?>? = emptyList(),
|
||||
) {
|
||||
@Composable
|
||||
fun RenderNotePreview() {
|
||||
@@ -78,6 +85,7 @@ data class LocalQuotedNostrEvent(
|
||||
RichContent(
|
||||
nostrEvent = nostrEvent,
|
||||
localQuotedNostrEvent = null,
|
||||
mentionedProfiles = mentionedProfiles,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import coil3.compose.AsyncImage
|
||||
fun RichContent(
|
||||
nostrEvent: NostrEvent,
|
||||
localQuotedNostrEvent: LocalQuotedNostrEvent?,
|
||||
mentionedProfiles: List<LocalMention?>?,
|
||||
style: TextStyle = MaterialTheme.typography.bodyLarge,
|
||||
color: Color = MaterialTheme.colorScheme.onSurface,
|
||||
linkColor: Color = Color.Unspecified,
|
||||
@@ -109,15 +110,14 @@ fun RichContent(
|
||||
val profileNames = remember(profilePubkeys) {
|
||||
val names = mutableMapOf<String, String>()
|
||||
|
||||
// TODO: Get profiles from profilePubkeys
|
||||
// if (mentionedProfiles?.isNotEmpty() == true) {
|
||||
// Logger.withTag("RichContent").d("mentionedProfiles: ${mentionedProfiles}")
|
||||
// for (pubkey in profilePubkeys) {
|
||||
// val mentionedProfile = mentionedProfiles.find { mentionedProfile -> mentionedProfile?.profile?.publicKey == pubkey }
|
||||
// names[pubkey] = mentionedProfile?.profile?.humanReadableNameOrPubkey()
|
||||
// ?: "${pubkey.take(8)}...${pubkey.takeLast(4)}"
|
||||
// }
|
||||
// }
|
||||
if (mentionedProfiles?.isNotEmpty() == true) {
|
||||
Logger.withTag("RichContent").d("mentionedProfiles: ${mentionedProfiles}")
|
||||
for (pubkey in profilePubkeys) {
|
||||
val mentionedProfile = mentionedProfiles?.find { mentionedProfile -> mentionedProfile?.profile?.publicKey == pubkey }
|
||||
names[pubkey] = mentionedProfile?.profile?.humanReadableNameOrPubkey()
|
||||
?: "${pubkey.take(8)}...${pubkey.takeLast(4)}"
|
||||
}
|
||||
}
|
||||
|
||||
names
|
||||
}
|
||||
|
||||
@@ -143,6 +143,7 @@ fun TextNoteEventDetail(
|
||||
),
|
||||
nostrEvent = localNostrEvent.nostrEvent,
|
||||
localQuotedNostrEvent = localNostrEvent.localQuotedNostrEvent,
|
||||
mentionedProfiles = localNostrEvent.mentionedProfiles
|
||||
)
|
||||
|
||||
Row(
|
||||
|
||||
@@ -68,6 +68,7 @@ fun LocalNostrEvent.ListView(
|
||||
profile = localRepostedNostrEvent.profile,
|
||||
localQuotedNostrEvent = null,
|
||||
localInReplyToNostrEvent = null,
|
||||
mentionedProfiles = localRepostedNostrEvent.mentionedProfiles,
|
||||
onNavigateToEvent = onNavigateToEvent
|
||||
)
|
||||
} else {
|
||||
@@ -103,6 +104,7 @@ fun LocalNostrEvent.ListView(
|
||||
profile = profile,
|
||||
localQuotedNostrEvent = localQuotedNostrEvent,
|
||||
localInReplyToNostrEvent = localInReplyToNostrEvent,
|
||||
mentionedProfiles = mentionedProfiles,
|
||||
onNavigateToEvent = onNavigateToEvent
|
||||
)
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ internal fun TextNoteFeedItem(
|
||||
profile: Profile?,
|
||||
localInReplyToNostrEvent: LocalInReplyToNostrEvent?,
|
||||
localQuotedNostrEvent: LocalQuotedNostrEvent?,
|
||||
mentionedProfiles: List<LocalMention?>?,
|
||||
onNavigateToEvent: (HexKey) -> Unit
|
||||
) {
|
||||
if (localInReplyToNostrEvent != null) {
|
||||
@@ -107,6 +108,7 @@ internal fun TextNoteFeedItem(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
nostrEvent = nostrEvent,
|
||||
localQuotedNostrEvent = localQuotedNostrEvent,
|
||||
mentionedProfiles = mentionedProfiles
|
||||
)
|
||||
|
||||
LazyRow(
|
||||
|
||||
Reference in New Issue
Block a user