Hide reply button in MessageDetails for group invitations

This commit is contained in:
Andrew 2024-04-12 14:12:08 +09:30
parent 1d9ac6ac10
commit 22660fd49c
2 changed files with 13 additions and 10 deletions

View File

@ -123,7 +123,7 @@ class MessageDetailActivity : PassphraseRequiredActionBarActivity() {
AppTheme {
MessageDetails(
state = state,
onReply = { setResultAndFinish(ON_REPLY) },
onReply = if (state.canReply) { { setResultAndFinish(ON_REPLY) } } else null,
onResend = state.error?.let { { setResultAndFinish(ON_RESEND) } },
onDelete = { setResultAndFinish(ON_DELETE) },
onClickImage = { viewModel.onClickImage(it) },
@ -145,7 +145,7 @@ class MessageDetailActivity : PassphraseRequiredActionBarActivity() {
@Composable
fun MessageDetails(
state: MessageDetailsState,
onReply: () -> Unit = {},
onReply: (() -> Unit)? = null,
onResend: (() -> Unit)? = null,
onDelete: () -> Unit = {},
onClickImage: (Int) -> Unit = {},
@ -214,18 +214,20 @@ fun CellMetadata(
@Composable
fun CellButtons(
onReply: () -> Unit = {},
onReply: (() -> Unit)? = null,
onResend: (() -> Unit)? = null,
onDelete: () -> Unit = {},
) {
Cell {
Column {
ItemButton(
stringResource(R.string.reply),
R.drawable.ic_message_details__reply,
onClick = onReply
)
Divider()
onReply?.let {
ItemButton(
stringResource(R.string.reply),
R.drawable.ic_message_details__reply,
onClick = it
)
Divider()
}
onResend?.let {
ItemButton(
stringResource(R.string.resend),

View File

@ -117,7 +117,7 @@ class MessageDetailsViewModel @Inject constructor(
Attachment(slide.details, slide.fileName.orNull(), slide.uri, slide is ImageSlide)
fun onClickImage(index: Int) {
val state = state.value ?: return
val state = state.value
val mmsRecord = state.mmsRecord ?: return
val slide = mmsRecord.slideDeck.slides[index] ?: return
// only open to downloaded images
@ -158,6 +158,7 @@ data class MessageDetailsState(
val thread: Recipient? = null,
) {
val fromTitle = GetString(R.string.message_details_header__from)
val canReply = record?.isOpenGroupInvitation != true
}
data class Attachment(