chore: improve line break handling #39
@@ -20,3 +20,7 @@ fun String.isImageUrl(): Boolean {
|
|||||||
val extension = this.substringAfterLast('.', "").lowercase()
|
val extension = this.substringAfterLast('.', "").lowercase()
|
||||||
return extension in imageExtensions
|
return extension in imageExtensions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun String.sanitizeName(): String {
|
||||||
|
return this.replace("\n", " ").replace("\r", " ").trim()
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ data class Profile(
|
|||||||
private val record by lazy { metadata.asRecord() }
|
private val record by lazy { metadata.asRecord() }
|
||||||
|
|
||||||
val name: String
|
val name: String
|
||||||
get() = record.displayName ?: record.name ?: publicKey.short()
|
get() = record.displayName?.sanitizeName() ?: record.name ?: publicKey.short()
|
||||||
|
|
||||||
val picture: String?
|
val picture: String?
|
||||||
get() = record.picture
|
get() = record.picture
|
||||||
|
|
||||||
|
|||||||
@@ -99,11 +99,13 @@ fun Room.uiStateFlow(
|
|||||||
val displayMembers = if (isGroup()) members.take(2) else members.take(1)
|
val displayMembers = if (isGroup()) members.take(2) else members.take(1)
|
||||||
|
|
||||||
if (!subject.isNullOrBlank()) {
|
if (!subject.isNullOrBlank()) {
|
||||||
return flowOf(RoomUiState(name = subject, isGroup = isGroup()))
|
return flowOf(RoomUiState(name = subject.sanitizeName(), isGroup = isGroup()))
|
||||||
}
|
}
|
||||||
|
|
||||||
return combine(displayMembers.map { nostrViewModel.getMetadata(it) }) { profiles ->
|
return combine(displayMembers.map { nostrViewModel.getMetadata(it) }) { profiles ->
|
||||||
val names = profiles.mapIndexed { i, profile -> profile?.name ?: displayMembers[i].short() }
|
val names = profiles.mapIndexed { i, profile ->
|
||||||
|
profile?.name?.sanitizeName() ?: displayMembers[i].short()
|
||||||
|
}
|
||||||
|
|
||||||
val name = when {
|
val name = when {
|
||||||
isGroup() -> {
|
isGroup() -> {
|
||||||
|
|||||||
Reference in New Issue
Block a user