mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2024-09-29 16:30:49 +00:00
Adding more info into flagged posts.
This commit is contained in:
parent
2992d9daf0
commit
6c27fe0828
@ -382,6 +382,20 @@ class Account(
|
|||||||
) // is not a reaction about a blocked post
|
) // is not a reaction about a blocked post
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getRelevantReports(note: Note): Set<Note> {
|
||||||
|
val followsPlusMe = userProfile().follows + userProfile()
|
||||||
|
|
||||||
|
val innerReports = if (note.event is RepostEvent) {
|
||||||
|
note.replyTo?.map { getRelevantReports(it) }?.flatten() ?: emptyList()
|
||||||
|
} else {
|
||||||
|
emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
|
return (note.reportsBy(followsPlusMe) +
|
||||||
|
(note.author?.reportsBy(followsPlusMe) ?: emptyList()) +
|
||||||
|
innerReports).toSet()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class AccountLiveData(private val account: Account): LiveData<AccountState>(AccountState(account)) {
|
class AccountLiveData(private val account: Account): LiveData<AccountState>(AccountState(account)) {
|
||||||
|
@ -1,15 +1,24 @@
|
|||||||
package com.vitorpamplona.amethyst.ui.note
|
package com.vitorpamplona.amethyst.ui.note
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material.Button
|
||||||
|
import androidx.compose.material.ButtonDefaults
|
||||||
import androidx.compose.material.Divider
|
import androidx.compose.material.Divider
|
||||||
|
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
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
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.navigation.NavController
|
||||||
|
import com.google.accompanist.flowlayout.FlowRow
|
||||||
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
|
import com.vitorpamplona.amethyst.model.User
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun BlankNote(modifier: Modifier = Modifier, isQuote: Boolean = false) {
|
fun BlankNote(modifier: Modifier = Modifier, isQuote: Boolean = false) {
|
||||||
@ -43,7 +52,7 @@ fun BlankNote(modifier: Modifier = Modifier, isQuote: Boolean = false) {
|
|||||||
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun HiddenNote(modifier: Modifier = Modifier, isQuote: Boolean = false) {
|
fun HiddenNote(reports: Set<Note>, loggedIn: User, modifier: Modifier = Modifier, isQuote: Boolean = false, navController: NavController, onClick: () -> Unit) {
|
||||||
Column(modifier = modifier) {
|
Column(modifier = modifier) {
|
||||||
Row(modifier = Modifier.padding(horizontal = if (!isQuote) 12.dp else 6.dp)) {
|
Row(modifier = Modifier.padding(horizontal = if (!isQuote) 12.dp else 6.dp)) {
|
||||||
Column(modifier = Modifier.padding(start = if (!isQuote) 10.dp else 5.dp)) {
|
Column(modifier = Modifier.padding(start = if (!isQuote) 10.dp else 5.dp)) {
|
||||||
@ -56,11 +65,35 @@ fun HiddenNote(modifier: Modifier = Modifier, isQuote: Boolean = false) {
|
|||||||
),
|
),
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
|
Column(horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier.padding(30.dp)) {
|
||||||
Text(
|
Text(
|
||||||
text = "Post was flagged as inappropriate",
|
text = "Post was flagged as inappropriate by",
|
||||||
modifier = Modifier.padding(30.dp),
|
|
||||||
color = Color.Gray,
|
color = Color.Gray,
|
||||||
)
|
)
|
||||||
|
FlowRow(modifier = Modifier.padding(top = 10.dp)) {
|
||||||
|
reports.forEach {
|
||||||
|
NoteAuthorPicture(
|
||||||
|
note = it,
|
||||||
|
navController = navController,
|
||||||
|
userAccount = loggedIn,
|
||||||
|
size = 35.dp
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button(
|
||||||
|
modifier = Modifier.padding(top = 10.dp),
|
||||||
|
onClick = onClick,
|
||||||
|
shape = RoundedCornerShape(20.dp),
|
||||||
|
colors = ButtonDefaults
|
||||||
|
.buttonColors(
|
||||||
|
backgroundColor = MaterialTheme.colors.primary
|
||||||
|
),
|
||||||
|
contentPadding = PaddingValues(vertical = 6.dp, horizontal = 16.dp)
|
||||||
|
) {
|
||||||
|
Text(text = "Show Anyway", color = Color.White)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Divider(
|
Divider(
|
||||||
|
@ -81,6 +81,7 @@ fun NoteCompose(
|
|||||||
val noteForReports = noteReportsState?.note ?: return
|
val noteForReports = noteReportsState?.note ?: return
|
||||||
|
|
||||||
var popupExpanded by remember { mutableStateOf(false) }
|
var popupExpanded by remember { mutableStateOf(false) }
|
||||||
|
var showHiddenNote by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
val context = LocalContext.current.applicationContext
|
val context = LocalContext.current.applicationContext
|
||||||
|
|
||||||
@ -89,11 +90,15 @@ fun NoteCompose(
|
|||||||
onClick = { },
|
onClick = { },
|
||||||
onLongClick = { popupExpanded = true },
|
onLongClick = { popupExpanded = true },
|
||||||
), isInnerNote)
|
), isInnerNote)
|
||||||
} else if (!account.isAcceptable(noteForReports)) {
|
} else if (!account.isAcceptable(noteForReports) && !showHiddenNote) {
|
||||||
HiddenNote(modifier.combinedClickable(
|
HiddenNote(
|
||||||
onClick = { },
|
account.getRelevantReports(noteForReports),
|
||||||
onLongClick = { popupExpanded = true },
|
account.userProfile(),
|
||||||
), isInnerNote)
|
modifier,
|
||||||
|
isInnerNote,
|
||||||
|
navController,
|
||||||
|
onClick = { showHiddenNote = true }
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
val isNew = routeForLastRead?.run {
|
val isNew = routeForLastRead?.run {
|
||||||
val lastTime = NotificationCache.load(this, context)
|
val lastTime = NotificationCache.load(this, context)
|
||||||
|
@ -168,10 +168,19 @@ fun NoteMaster(baseNote: Note, accountViewModel: AccountViewModel, navController
|
|||||||
val accountState by accountViewModel.accountLiveData.observeAsState()
|
val accountState by accountViewModel.accountLiveData.observeAsState()
|
||||||
val account = accountState?.account ?: return
|
val account = accountState?.account ?: return
|
||||||
|
|
||||||
|
var showHiddenNote by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
if (note?.event == null) {
|
if (note?.event == null) {
|
||||||
BlankNote()
|
BlankNote()
|
||||||
} else if (!account.isAcceptable(noteForReports)) {
|
} else if (!account.isAcceptable(noteForReports)) {
|
||||||
HiddenNote()
|
HiddenNote(
|
||||||
|
account.getRelevantReports(noteForReports),
|
||||||
|
account.userProfile(),
|
||||||
|
Modifier,
|
||||||
|
false,
|
||||||
|
navController,
|
||||||
|
onClick = { showHiddenNote = true }
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
Column(
|
Column(
|
||||||
Modifier
|
Modifier
|
||||||
|
Loading…
Reference in New Issue
Block a user