feat: do not show messages from blocked users
Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
parent
71895c348f
commit
1d7bc309a3
|
|
@ -36,6 +36,7 @@ import androidx.compose.material3.surfaceColorAtElevation
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.CompositionLocalProvider
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.compose.runtime.key
|
import androidx.compose.runtime.key
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
|
@ -44,6 +45,7 @@ import androidx.compose.ui.graphics.Brush
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.text.font.FontStyle
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
|
@ -181,11 +183,50 @@ fun Message(
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val authorIsBlocked = remember(author) { author.relationship == "Blocked" }
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
if (message.tail == false) {
|
if (message.tail == false) {
|
||||||
Spacer(modifier = Modifier.height(10.dp))
|
Spacer(modifier = Modifier.height(10.dp))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (authorIsBlocked) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.combinedClickable(
|
||||||
|
onClick = {},
|
||||||
|
onDoubleClick = {},
|
||||||
|
onLongClick = {
|
||||||
|
onMessageContextMenu()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.padding(horizontal = 10.dp)
|
||||||
|
.fillMaxWidth()
|
||||||
|
) {
|
||||||
|
UserAvatarWidthPlaceholder()
|
||||||
|
|
||||||
|
Column(modifier = Modifier.padding(start = 10.dp)) {
|
||||||
|
Row(
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
modifier = Modifier.padding(vertical = 8.dp)
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
painter = painterResource(R.drawable.ic_close_octagon_24dp),
|
||||||
|
contentDescription = null
|
||||||
|
)
|
||||||
|
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.message_blocked),
|
||||||
|
fontSize = 12.sp,
|
||||||
|
color = LocalContentColor.current.copy(alpha = 0.5f),
|
||||||
|
fontStyle = FontStyle.Italic
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.then(
|
modifier = Modifier.then(
|
||||||
if (message.mentions?.contains(RevoltAPI.selfId) == true) {
|
if (message.mentions?.contains(RevoltAPI.selfId) == true) {
|
||||||
|
|
@ -334,7 +375,10 @@ fun Message(
|
||||||
when (attachment.metadata?.type) {
|
when (attachment.metadata?.type) {
|
||||||
"Image" -> {
|
"Image" -> {
|
||||||
attachmentView.launch(
|
attachmentView.launch(
|
||||||
Intent(context, ImageViewActivity::class.java).apply {
|
Intent(
|
||||||
|
context,
|
||||||
|
ImageViewActivity::class.java
|
||||||
|
).apply {
|
||||||
putExtra("autumnResource", attachment)
|
putExtra("autumnResource", attachment)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -342,7 +386,10 @@ fun Message(
|
||||||
|
|
||||||
"Video" -> {
|
"Video" -> {
|
||||||
attachmentView.launch(
|
attachmentView.launch(
|
||||||
Intent(context, VideoViewActivity::class.java).apply {
|
Intent(
|
||||||
|
context,
|
||||||
|
VideoViewActivity::class.java
|
||||||
|
).apply {
|
||||||
putExtra("autumnResource", attachment)
|
putExtra("autumnResource", attachment)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -423,7 +470,11 @@ fun Message(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.clip(MaterialTheme.shapes.small)
|
.clip(MaterialTheme.shapes.small)
|
||||||
.background(MaterialTheme.colorScheme.surfaceColorAtElevation(2.dp))
|
.background(
|
||||||
|
MaterialTheme.colorScheme.surfaceColorAtElevation(
|
||||||
|
2.dp
|
||||||
|
)
|
||||||
|
)
|
||||||
.clickable(onClick = onAddReaction)
|
.clickable(onClick = onAddReaction)
|
||||||
.padding(8.dp)
|
.padding(8.dp)
|
||||||
) {
|
) {
|
||||||
|
|
@ -441,3 +492,4 @@ fun Message(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:height="24dp"
|
||||||
|
android:width="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#ffffff"
|
||||||
|
android:pathData="M8.27,3L3,8.27V15.73L8.27,21H15.73L21,15.73V8.27L15.73,3M8.41,7L12,10.59L15.59,7L17,8.41L13.41,12L17,15.59L15.59,17L12,13.41L8.41,17L7,15.59L10.59,12L7,8.41" />
|
||||||
|
</vector>
|
||||||
|
|
@ -187,6 +187,8 @@
|
||||||
<string name="reply_message_not_cached">Unknown message</string>
|
<string name="reply_message_not_cached">Unknown message</string>
|
||||||
<string name="reply_message_empty_has_attachments">Sent attachments</string>
|
<string name="reply_message_empty_has_attachments">Sent attachments</string>
|
||||||
|
|
||||||
|
<string name="message_blocked">Blocked message</string>
|
||||||
|
|
||||||
<string name="system_message_ownership_changed_alt">Ownership changed</string>
|
<string name="system_message_ownership_changed_alt">Ownership changed</string>
|
||||||
<string name="system_message_channel_icon_changed_alt">Channel icon changed</string>
|
<string name="system_message_channel_icon_changed_alt">Channel icon changed</string>
|
||||||
<string name="system_message_channel_description_changed_alt">Channel description changed</string>
|
<string name="system_message_channel_description_changed_alt">Channel description changed</string>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue