mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-28 15:47:43 +02:00
Correctly addressing Preview of images when posts have been reported.
This commit is contained in:
@@ -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),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user