Bug fix on profiles in a chat
This commit is contained in:
@@ -52,7 +52,7 @@ abstract class NostrNip17Dao(
|
||||
if (localChatRoom != null) {
|
||||
return localChatRoom
|
||||
} else {
|
||||
val profiles = database.profileDao().getAllProfiles()
|
||||
val profiles = database.profileDao().getProfileByPublicKeys(hexKeys)
|
||||
|
||||
if (profiles.isNotEmpty()) {
|
||||
// Create new chatRoom
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ac.cord.auxiliary.compose.database.model.intermdiate
|
||||
|
||||
import ac.cord.auxiliary.compose.database.model.ChatRoom
|
||||
import ac.cord.auxiliary.compose.database.model.Mention
|
||||
import ac.cord.auxiliary.compose.database.model.Participant
|
||||
import ac.cord.auxiliary.compose.database.model.Post
|
||||
import ac.cord.auxiliary.compose.database.model.Profile
|
||||
@@ -10,5 +11,10 @@ import androidx.room3.Relation
|
||||
data class LocalChatRoom(
|
||||
@Embedded val chatRoom: ChatRoom,
|
||||
|
||||
// val participants: List<Participant>
|
||||
@Relation(
|
||||
entity = Participant::class,
|
||||
parentColumns = ["id"],
|
||||
entityColumns = ["chatRoomId"],
|
||||
)
|
||||
val participants: List<LocalParticipant> = emptyList(),
|
||||
)
|
||||
|
||||
@@ -83,7 +83,11 @@ fun ChatRoomDetailScreen(
|
||||
Column(
|
||||
modifier = Modifier.padding(innerPadding)
|
||||
) {
|
||||
Text("Messages will appear here...")
|
||||
chatRoomDetailUIState.localChatRoom.participants.forEach { participant ->
|
||||
Text(
|
||||
participant.profile?.humanReadableNameOrPubkey() ?: participant.participant.participantPublicKey
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ class ChatRoomListViewModel(
|
||||
nostrRepository.observeChatRoomsByPublicKey(
|
||||
publicKey
|
||||
).distinctUntilChanged().collect {
|
||||
logger.d("ChatRoomList: $it")
|
||||
chatRoomListUIState = ChatRoomListUIState.Loaded(
|
||||
chatRoomList = it
|
||||
)
|
||||
@@ -153,8 +154,11 @@ class ChatRoomListViewModel(
|
||||
modifier = Modifier.padding(20.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
// TODO: Remove active user pubKey
|
||||
val participantNames = localChatRoom.participants.map { it.profile?.humanReadableNameOrPubkey() ?: "unknown participant" }
|
||||
|
||||
Text(
|
||||
text = localChatRoom.chatRoom.subject ?: "Unnamed chat"
|
||||
text = localChatRoom.chatRoom.subject ?: participantNames.joinToString { ", " }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user