Improve the view

This commit is contained in:
Kgothatso Ngako
2026-03-31 21:13:49 +02:00
parent b01088a74f
commit 79044514f8
3 changed files with 21 additions and 3 deletions

View File

@@ -9,10 +9,11 @@ import androidx.room.Query
import androidx.room.Upsert
import com.vitorpamplona.quartz.nip01Core.core.Kind
import kotlinx.coroutines.flow.Flow
import kotlin.time.Instant
@Dao
interface NostrEventDao {
@Query("SELECT * FROM NostrEvent WHERE kind in (:kinds) ORDER BY savedAt DESC")
@Query("SELECT * FROM NostrEvent WHERE kind in (:kinds) ORDER BY createdAt DESC")
fun observeNostrEvents(kinds: Array<Kind>): Flow<List<LocalNostrEvent>>
@Query("SELECT * FROM NostrEvent WHERE kind in (:kinds) ORDER BY savedAt DESC")

View File

@@ -34,6 +34,7 @@ import kotlinx.coroutines.flow.Flow
import kotlin.collections.emptyMap
import kotlin.collections.plus
import kotlin.time.Clock
import kotlin.time.Duration.Companion.seconds
import kotlin.time.Instant
class DatabaseNostrRepository(
@@ -298,8 +299,11 @@ class DatabaseNostrRepository(
}
override suspend fun observeNostrFeed(): Flow<List<LocalNostrEvent>> {
val thirtySecondsAgo = Clock.System.now().minus(30.seconds)
return database.nostrEventDao().observeNostrEvents(
kinds = arrayOf(
MetadataEvent.KIND,
TextNoteEvent.KIND,
RepostEvent.KIND,
LnZapEvent.KIND

View File

@@ -18,7 +18,9 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Person
import androidx.compose.material3.AssistChip
import androidx.compose.material3.ElevatedCard
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialShapes
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.SuggestionChip
import androidx.compose.material3.Surface
@@ -100,12 +102,15 @@ fun LocalNostrEvent.ListView(
TextNoteFeedItem(
nostrEvent = nostrEvent,
profile = profile,
taggedAuthor = taggedAuthor,
taggedNostrEvent = taggedNostrEvent,
onNavigateToEvent = onNavigateToEvent
)
}
}
}
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
@Composable
private fun TextNoteFeedItem(
nostrEvent: NostrEvent,
@@ -115,9 +120,16 @@ private fun TextNoteFeedItem(
onNavigateToEvent: (HexKey) -> Unit
) {
if (nostrEvent.kind == 1 && taggedNostrEvent != null) {
Row {
Row(
modifier = Modifier.fillMaxWidth().padding(
horizontal = 20.dp
),
horizontalArrangement = Arrangement.End,
verticalAlignment = Alignment.CenterVertically
) {
Text(
"In reply to"
"In reply to ",
style = MaterialTheme.typography.labelSmall
)
Text(
@@ -126,6 +138,7 @@ private fun TextNoteFeedItem(
onNavigateToEvent.invoke(taggedNostrEvent.id)
}
),
style = MaterialTheme.typography.labelLargeEmphasized,
text = taggedAuthor?.displayName ?: taggedAuthor?.userName ?: "loading information..."
)
}