fix: app crash when message id is null #28
@@ -234,9 +234,10 @@ fun ChatScreen(id: Long, screening: Boolean = false) {
|
|||||||
) {
|
) {
|
||||||
groupedMessages.forEach { (dateHeader, messagesInGroup) ->
|
groupedMessages.forEach { (dateHeader, messagesInGroup) ->
|
||||||
items(
|
items(
|
||||||
messagesInGroup,
|
items = messagesInGroup,
|
||||||
key = { it.id()?.toBech32()!! }) { event ->
|
key = { it.id()?.toBech32() ?: it.hashCode() }
|
||||||
ChatMessage(event)
|
) {
|
||||||
|
ChatMessage(it)
|
||||||
}
|
}
|
||||||
item {
|
item {
|
||||||
DateSeparator(dateHeader)
|
DateSeparator(dateHeader)
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ fun Room.nameFlow(viewModel: NostrViewModel): Flow<String> {
|
|||||||
return combine(displayMembers.map { viewModel.getMetadata(it) }) { metadataArray ->
|
return combine(displayMembers.map { viewModel.getMetadata(it) }) { metadataArray ->
|
||||||
val names = metadataArray.mapIndexed { i, metadata ->
|
val names = metadataArray.mapIndexed { i, metadata ->
|
||||||
val profile = metadata?.asRecord()
|
val profile = metadata?.asRecord()
|
||||||
profile?.name?.takeIf { it.isNotBlank() }
|
profile?.displayName?.takeIf { it.isNotBlank() }
|
||||||
?: profile?.displayName?.takeIf { it.isNotBlank() }
|
?: profile?.name?.takeIf { it.isNotBlank() }
|
||||||
?: displayMembers[i].short()
|
?: displayMembers[i].short()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -473,7 +473,7 @@ class Nostr {
|
|||||||
|
|
||||||
// Decrypt the rumor
|
// Decrypt the rumor
|
||||||
val rumor = signer.nip44DecryptAsync(sealEvent.author(), sealEvent.content())
|
val rumor = signer.nip44DecryptAsync(sealEvent.author(), sealEvent.content())
|
||||||
val unsignedEvent = UnsignedEvent.fromJson(rumor)
|
val unsignedEvent = UnsignedEvent.fromJson(rumor).ensureId()
|
||||||
|
|
||||||
// Ensure the rumor author matches the seal
|
// Ensure the rumor author matches the seal
|
||||||
if (unsignedEvent.author() != sealEvent.author()) {
|
if (unsignedEvent.author() != sealEvent.author()) {
|
||||||
@@ -813,7 +813,7 @@ class Nostr {
|
|||||||
// Merge the events
|
// Merge the events
|
||||||
return events
|
return events
|
||||||
?.toVec()
|
?.toVec()
|
||||||
?.map { UnsignedEvent.fromJson(it.content()) }
|
?.map { UnsignedEvent.fromJson(it.content()).ensureId() }
|
||||||
// Filter out events without public keys (receivers)
|
// Filter out events without public keys (receivers)
|
||||||
?.filter { it.tags().publicKeys().isNotEmpty() }
|
?.filter { it.tags().publicKeys().isNotEmpty() }
|
||||||
?.sortedByDescending { it.createdAt().asSecs() } ?: emptyList()
|
?.sortedByDescending { it.createdAt().asSecs() } ?: emptyList()
|
||||||
|
|||||||
Reference in New Issue
Block a user