Correctly addressing Preview of images when posts have been reported.

pull/87/head
Vitor Pamplona 2023-02-05 18:12:11 -05:00
rodzic eb41f22bae
commit ff087e3dea
4 zmienionych plików z 38 dodań i 25 usunięć

Wyświetl plik

@ -64,7 +64,7 @@ fun isValidURL(url: String?): Boolean {
}
@Composable
fun RichTextViewer(content: String, blockPreview: Boolean, tags: List<List<String>>?, navController: NavController) {
fun RichTextViewer(content: String, canPreview: Boolean, tags: List<List<String>>?, navController: NavController) {
val translatedTextState = remember {
mutableStateOf(ResultOrError(content, null, null, null))
}
@ -88,26 +88,7 @@ fun RichTextViewer(content: String, blockPreview: Boolean, tags: List<List<Strin
FlowRow() {
paragraph.split(' ').forEach { word: String ->
if (blockPreview) {
if (isValidURL(word)) {
ClickableUrl("$word ", word)
} else if (Patterns.EMAIL_ADDRESS.matcher(word).matches()) {
ClickableEmail(word)
} else if (Patterns.PHONE.matcher(word).matches() && word.length > 6) {
ClickablePhone(word)
} else if (noProtocolUrlValidator.matcher(word).matches()) {
ClickableUrl("https://$word", word)
} else if (tagIndex.matcher(word).matches() && tags != null) {
TagLink(word, tags, navController)
} else if (isBechLink(word)) {
BechLink(word, navController)
} else {
Text(
text = "$word ",
style = LocalTextStyle.current.copy(textDirection = TextDirection.Content),
)
}
} else {
if (canPreview) {
// Explicit URL
val lnInvoice = LnInvoiceUtil.findInvoice(word)
if (lnInvoice != null) {
@ -137,6 +118,25 @@ fun RichTextViewer(content: String, blockPreview: Boolean, tags: List<List<Strin
style = LocalTextStyle.current.copy(textDirection = TextDirection.Content),
)
}
} else {
if (isValidURL(word)) {
ClickableUrl("$word ", word)
} else if (Patterns.EMAIL_ADDRESS.matcher(word).matches()) {
ClickableEmail(word)
} else if (Patterns.PHONE.matcher(word).matches() && word.length > 6) {
ClickablePhone(word)
} else if (noProtocolUrlValidator.matcher(word).matches()) {
ClickableUrl("https://$word", word)
} else if (tagIndex.matcher(word).matches() && tags != null) {
TagLink(word, tags, navController)
} else if (isBechLink(word)) {
BechLink(word, navController)
} else {
Text(
text = "$word ",
style = LocalTextStyle.current.copy(textDirection = TextDirection.Content),
)
}
}
}
}

Wyświetl plik

@ -203,17 +203,21 @@ fun ChatroomMessageCompose(baseNote: Note, routeForLastRead: String?, innerQuote
} else {
val eventContent = accountViewModel.decrypt(note)
val canPreview = note.author == accountUser
|| (note.author?.let { accountUser.isFollowing(it) } ?: true )
|| !noteForReports.hasAnyReports()
if (eventContent != null) {
RichTextViewer(
eventContent,
noteForReports.hasAnyReports(),
canPreview,
note.event?.tags,
navController
)
} else {
RichTextViewer(
"Could Not decrypt the message",
false,
true,
note.event?.tags,
navController
)

Wyświetl plik

@ -246,8 +246,12 @@ fun NoteCompose(
}
} else {
val eventContent = note.event?.content
val canPreview = note.author == account.userProfile()
|| (note.author?.let { account.userProfile().isFollowing(it) } ?: true )
|| !noteForReports.hasAnyReports()
if (eventContent != null) {
RichTextViewer(eventContent, noteForReports.hasAnyReports(), note.event?.tags, navController)
RichTextViewer(eventContent, canPreview, note.event?.tags, navController)
}
ReactionsRow(note, accountViewModel)

Wyświetl plik

@ -220,8 +220,13 @@ fun NoteMaster(baseNote: Note, accountViewModel: AccountViewModel, navController
Row(modifier = Modifier.padding(horizontal = 12.dp)) {
Column() {
val eventContent = note.event?.content
val canPreview = note.author == account.userProfile()
|| (note.author?.let { account.userProfile().isFollowing(it) } ?: true )
|| !noteForReports.hasAnyReports()
if (eventContent != null) {
RichTextViewer(eventContent, noteForReports.hasAnyReports(), note.event?.tags, navController)
RichTextViewer(eventContent, canPreview, note.event?.tags, navController)
}
ReactionsRow(note, accountViewModel)