Not display any previews if the note has a report.
This commit is contained in:
@@ -130,6 +130,12 @@ class Note(val idHex: String) {
|
|||||||
return reports.filter { it.author in users }
|
return reports.filter { it.author in users }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun hasAnyReports(): Boolean {
|
||||||
|
val dayAgo = Date().time / 1000 - 24*60*60
|
||||||
|
return author?.reports?.filter { it.event?.createdAt ?: 0 > dayAgo }?.isNotEmpty() ?: false
|
||||||
|
|| reports.isNotEmpty()
|
||||||
|
}
|
||||||
|
|
||||||
fun directlyCiteUsers(): Set<User> {
|
fun directlyCiteUsers(): Set<User> {
|
||||||
val matcher = tagSearch.matcher(event?.content ?: "")
|
val matcher = tagSearch.matcher(event?.content ?: "")
|
||||||
val returningList = mutableSetOf<User>()
|
val returningList = mutableSetOf<User>()
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ fun isValidURL(url: String?): Boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun RichTextViewer(content: String, tags: List<List<String>>?, navController: NavController) {
|
fun RichTextViewer(content: String, blockPreview: 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))
|
||||||
}
|
}
|
||||||
@@ -87,34 +87,56 @@ fun RichTextViewer(content: String, tags: List<List<String>>?, navController: Na
|
|||||||
|
|
||||||
FlowRow() {
|
FlowRow() {
|
||||||
paragraph.split(' ').forEach { word: String ->
|
paragraph.split(' ').forEach { word: String ->
|
||||||
// Explicit URL
|
|
||||||
val lnInvoice = LnInvoiceUtil.findInvoice(word)
|
if (blockPreview) {
|
||||||
if (lnInvoice != null) {
|
if (isValidURL(word)) {
|
||||||
InvoicePreview(lnInvoice)
|
ClickableUrl("$word ", word)
|
||||||
} else if (isValidURL(word)) {
|
} else if (Patterns.EMAIL_ADDRESS.matcher(word).matches()) {
|
||||||
val removedParamsFromUrl = word.split("?")[0].toLowerCase()
|
ClickableEmail(word)
|
||||||
if (imageExtension.matcher(removedParamsFromUrl).matches()) {
|
} else if (Patterns.PHONE.matcher(word).matches() && word.length > 6) {
|
||||||
ZoomableImageView(word)
|
ClickablePhone(word)
|
||||||
} else if (videoExtension.matcher(removedParamsFromUrl).matches()) {
|
} else if (noProtocolUrlValidator.matcher(word).matches()) {
|
||||||
VideoView(word)
|
ClickableUrl("https://$word", word)
|
||||||
|
} else if (tagIndex.matcher(word).matches() && tags != null) {
|
||||||
|
TagLink(word, tags, navController)
|
||||||
|
} else if (isBechLink(word)) {
|
||||||
|
BechLink(word, navController)
|
||||||
} else {
|
} else {
|
||||||
UrlPreview(word, word)
|
Text(
|
||||||
|
text = "$word ",
|
||||||
|
style = LocalTextStyle.current.copy(textDirection = TextDirection.Content),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} 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()) {
|
|
||||||
UrlPreview("https://$word", word)
|
|
||||||
} else if (tagIndex.matcher(word).matches() && tags != null) {
|
|
||||||
TagLink(word, tags, navController)
|
|
||||||
} else if (isBechLink(word)) {
|
|
||||||
BechLink(word, navController)
|
|
||||||
} else {
|
} else {
|
||||||
Text(
|
// Explicit URL
|
||||||
text = "$word ",
|
val lnInvoice = LnInvoiceUtil.findInvoice(word)
|
||||||
style = LocalTextStyle.current.copy(textDirection = TextDirection.Content),
|
if (lnInvoice != null) {
|
||||||
)
|
InvoicePreview(lnInvoice)
|
||||||
|
} else if (isValidURL(word)) {
|
||||||
|
val removedParamsFromUrl = word.split("?")[0].toLowerCase()
|
||||||
|
if (imageExtension.matcher(removedParamsFromUrl).matches()) {
|
||||||
|
ZoomableImageView(word)
|
||||||
|
} else if (videoExtension.matcher(removedParamsFromUrl).matches()) {
|
||||||
|
VideoView(word)
|
||||||
|
} else {
|
||||||
|
UrlPreview(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()) {
|
||||||
|
UrlPreview("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),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import androidx.compose.foundation.layout.widthIn
|
|||||||
import androidx.compose.foundation.layout.wrapContentWidth
|
import androidx.compose.foundation.layout.wrapContentWidth
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material.LocalTextStyle
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material.MaterialTheme
|
||||||
import androidx.compose.material.Surface
|
import androidx.compose.material.Surface
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
@@ -32,6 +33,7 @@ import androidx.compose.ui.graphics.Color
|
|||||||
import androidx.compose.ui.graphics.Shape
|
import androidx.compose.ui.graphics.Shape
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.text.style.TextDirection
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
@@ -201,19 +203,21 @@ fun ChatroomMessageCompose(baseNote: Note, routeForLastRead: String?, innerQuote
|
|||||||
} else {
|
} else {
|
||||||
val eventContent = accountViewModel.decrypt(note)
|
val eventContent = accountViewModel.decrypt(note)
|
||||||
|
|
||||||
if (eventContent != null)
|
if (eventContent != null) {
|
||||||
RichTextViewer(
|
RichTextViewer(
|
||||||
eventContent,
|
eventContent,
|
||||||
|
noteForReports.hasAnyReports(),
|
||||||
note.event?.tags,
|
note.event?.tags,
|
||||||
navController
|
navController
|
||||||
)
|
)
|
||||||
else
|
} else {
|
||||||
RichTextViewer(
|
RichTextViewer(
|
||||||
"Could Not decrypt the message",
|
"Could Not decrypt the message",
|
||||||
|
false,
|
||||||
note.event?.tags,
|
note.event?.tags,
|
||||||
navController
|
navController
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -247,17 +247,7 @@ fun NoteCompose(
|
|||||||
} else {
|
} else {
|
||||||
val eventContent = note.event?.content
|
val eventContent = note.event?.content
|
||||||
if (eventContent != null) {
|
if (eventContent != null) {
|
||||||
if (note.reports.size > 0) {
|
RichTextViewer(eventContent, noteForReports.hasAnyReports(), note.event?.tags, navController)
|
||||||
// Doesn't load images
|
|
||||||
Row() {
|
|
||||||
Text(
|
|
||||||
text = eventContent,
|
|
||||||
style = LocalTextStyle.current.copy(textDirection = TextDirection.Content),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
RichTextViewer(eventContent, note.event?.tags, navController)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReactionsRow(note, accountViewModel)
|
ReactionsRow(note, accountViewModel)
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import androidx.compose.foundation.lazy.itemsIndexed
|
|||||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.material.Divider
|
import androidx.compose.material.Divider
|
||||||
|
import androidx.compose.material.LocalTextStyle
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material.MaterialTheme
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@@ -33,6 +34,7 @@ import androidx.compose.ui.geometry.Offset
|
|||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
|
import androidx.compose.ui.text.style.TextDirection
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import coil.compose.AsyncImage
|
import coil.compose.AsyncImage
|
||||||
import coil.compose.rememberAsyncImagePainter
|
import coil.compose.rememberAsyncImagePainter
|
||||||
@@ -218,8 +220,9 @@ 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
|
||||||
if (eventContent != null)
|
if (eventContent != null) {
|
||||||
RichTextViewer(eventContent, note.event?.tags, navController)
|
RichTextViewer(eventContent, noteForReports.hasAnyReports(), note.event?.tags, navController)
|
||||||
|
}
|
||||||
|
|
||||||
ReactionsRow(note, accountViewModel)
|
ReactionsRow(note, accountViewModel)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user