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
|
@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 {
|
val translatedTextState = remember {
|
||||||
mutableStateOf(ResultOrError(content, null, null, null))
|
mutableStateOf(ResultOrError(content, null, null, null))
|
||||||
}
|
}
|
||||||
@@ -88,26 +88,7 @@ fun RichTextViewer(content: String, blockPreview: Boolean, tags: List<List<Strin
|
|||||||
FlowRow() {
|
FlowRow() {
|
||||||
paragraph.split(' ').forEach { word: String ->
|
paragraph.split(' ').forEach { word: String ->
|
||||||
|
|
||||||
if (blockPreview) {
|
if (canPreview) {
|
||||||
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 {
|
|
||||||
// Explicit URL
|
// Explicit URL
|
||||||
val lnInvoice = LnInvoiceUtil.findInvoice(word)
|
val lnInvoice = LnInvoiceUtil.findInvoice(word)
|
||||||
if (lnInvoice != null) {
|
if (lnInvoice != null) {
|
||||||
@@ -137,6 +118,25 @@ fun RichTextViewer(content: String, blockPreview: Boolean, tags: List<List<Strin
|
|||||||
style = LocalTextStyle.current.copy(textDirection = TextDirection.Content),
|
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 {
|
} else {
|
||||||
val eventContent = accountViewModel.decrypt(note)
|
val eventContent = accountViewModel.decrypt(note)
|
||||||
|
|
||||||
|
val canPreview = note.author == accountUser
|
||||||
|
|| (note.author?.let { accountUser.isFollowing(it) } ?: true )
|
||||||
|
|| !noteForReports.hasAnyReports()
|
||||||
|
|
||||||
if (eventContent != null) {
|
if (eventContent != null) {
|
||||||
RichTextViewer(
|
RichTextViewer(
|
||||||
eventContent,
|
eventContent,
|
||||||
noteForReports.hasAnyReports(),
|
canPreview,
|
||||||
note.event?.tags,
|
note.event?.tags,
|
||||||
navController
|
navController
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
RichTextViewer(
|
RichTextViewer(
|
||||||
"Could Not decrypt the message",
|
"Could Not decrypt the message",
|
||||||
false,
|
true,
|
||||||
note.event?.tags,
|
note.event?.tags,
|
||||||
navController
|
navController
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -246,8 +246,12 @@ fun NoteCompose(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val eventContent = note.event?.content
|
val eventContent = note.event?.content
|
||||||
|
val canPreview = note.author == account.userProfile()
|
||||||
|
|| (note.author?.let { account.userProfile().isFollowing(it) } ?: true )
|
||||||
|
|| !noteForReports.hasAnyReports()
|
||||||
|
|
||||||
if (eventContent != null) {
|
if (eventContent != null) {
|
||||||
RichTextViewer(eventContent, noteForReports.hasAnyReports(), note.event?.tags, navController)
|
RichTextViewer(eventContent, canPreview, note.event?.tags, navController)
|
||||||
}
|
}
|
||||||
|
|
||||||
ReactionsRow(note, accountViewModel)
|
ReactionsRow(note, accountViewModel)
|
||||||
|
|||||||
@@ -220,8 +220,13 @@ fun NoteMaster(baseNote: Note, accountViewModel: AccountViewModel, navController
|
|||||||
Row(modifier = Modifier.padding(horizontal = 12.dp)) {
|
Row(modifier = Modifier.padding(horizontal = 12.dp)) {
|
||||||
Column() {
|
Column() {
|
||||||
val eventContent = note.event?.content
|
val eventContent = note.event?.content
|
||||||
|
|
||||||
|
val canPreview = note.author == account.userProfile()
|
||||||
|
|| (note.author?.let { account.userProfile().isFollowing(it) } ?: true )
|
||||||
|
|| !noteForReports.hasAnyReports()
|
||||||
|
|
||||||
if (eventContent != null) {
|
if (eventContent != null) {
|
||||||
RichTextViewer(eventContent, noteForReports.hasAnyReports(), note.event?.tags, navController)
|
RichTextViewer(eventContent, canPreview, note.event?.tags, navController)
|
||||||
}
|
}
|
||||||
|
|
||||||
ReactionsRow(note, accountViewModel)
|
ReactionsRow(note, accountViewModel)
|
||||||
|
|||||||
Reference in New Issue
Block a user