mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 03:48:12 +03:00
Add reply action for poll end events.
This commit is contained in:
parent
374445eed6
commit
b53615a8d7
6 changed files with 20 additions and 6 deletions
|
@ -3501,4 +3501,5 @@
|
|||
<string name="message_reply_to_sender_sent_video">sent a video.</string>
|
||||
<string name="message_reply_to_sender_sent_sticker">sent a sticker.</string>
|
||||
<string name="message_reply_to_sender_created_poll">created a poll.</string>
|
||||
<string name="message_reply_to_sender_ended_poll">ended a poll.</string>
|
||||
</resources>
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.matrix.android.sdk.api.session.room.timeline.getLastMessageContent
|
|||
|
||||
fun TimelineEvent.canReact(): Boolean {
|
||||
// Only event of type EventType.MESSAGE, EventType.STICKER and EventType.POLL_START are supported for the moment
|
||||
return root.getClearType() in listOf(EventType.MESSAGE, EventType.STICKER) + EventType.POLL_START.values &&
|
||||
return root.getClearType() in listOf(EventType.MESSAGE, EventType.STICKER) + EventType.POLL_START.values + EventType.POLL_END.values &&
|
||||
root.sendState == SendState.SYNCED &&
|
||||
!root.isRedacted()
|
||||
}
|
||||
|
|
|
@ -25,8 +25,14 @@ import javax.inject.Inject
|
|||
class CheckIfCanReplyEventUseCase @Inject constructor() {
|
||||
|
||||
fun execute(event: TimelineEvent, messageContent: MessageContent?, actionPermissions: ActionPermissions): Boolean {
|
||||
// Only EventType.MESSAGE, EventType.POLL_START and EventType.STATE_ROOM_BEACON_INFO event types are supported for the moment
|
||||
if (event.root.getClearType() !in EventType.STATE_ROOM_BEACON_INFO.values + EventType.POLL_START.values + EventType.MESSAGE) return false
|
||||
// Only EventType.MESSAGE, EventType.POLL_START, EventType.POLL_END and EventType.STATE_ROOM_BEACON_INFO event types are supported for the moment
|
||||
if (event.root.getClearType() !in
|
||||
EventType.STATE_ROOM_BEACON_INFO.values +
|
||||
EventType.POLL_START.values +
|
||||
EventType.POLL_END.values +
|
||||
EventType.MESSAGE
|
||||
) return false
|
||||
|
||||
if (!actionPermissions.canSendMessage) return false
|
||||
return when (messageContent?.msgType) {
|
||||
MessageType.MSGTYPE_TEXT,
|
||||
|
@ -37,6 +43,7 @@ class CheckIfCanReplyEventUseCase @Inject constructor() {
|
|||
MessageType.MSGTYPE_AUDIO,
|
||||
MessageType.MSGTYPE_FILE,
|
||||
MessageType.MSGTYPE_POLL_START,
|
||||
MessageType.MSGTYPE_POLL_END,
|
||||
MessageType.MSGTYPE_BEACON_INFO,
|
||||
MessageType.MSGTYPE_LOCATION -> true
|
||||
else -> false
|
||||
|
|
|
@ -498,6 +498,7 @@ class MessageActionsViewModel @AssistedInject constructor(
|
|||
MessageType.MSGTYPE_AUDIO,
|
||||
MessageType.MSGTYPE_FILE,
|
||||
MessageType.MSGTYPE_POLL_START,
|
||||
MessageType.MSGTYPE_POLL_END,
|
||||
MessageType.MSGTYPE_STICKER_LOCAL -> event.root.threadDetails?.isRootThread ?: false
|
||||
else -> false
|
||||
}
|
||||
|
@ -529,8 +530,8 @@ class MessageActionsViewModel @AssistedInject constructor(
|
|||
}
|
||||
|
||||
private fun canViewReactions(event: TimelineEvent): Boolean {
|
||||
// Only event of type EventType.MESSAGE, EventType.STICKER and EventType.POLL_START are supported for the moment
|
||||
if (event.root.getClearType() !in listOf(EventType.MESSAGE, EventType.STICKER) + EventType.POLL_START.values) return false
|
||||
// Only event of type EventType.MESSAGE, EventType.STICKER, EventType.POLL_START, EventType.POLL_END are supported for the moment
|
||||
if (event.root.getClearType() !in listOf(EventType.MESSAGE, EventType.STICKER) + EventType.POLL_START.values + EventType.POLL_END.values) return false
|
||||
return event.annotations?.reactionsSummary?.isNotEmpty() ?: false
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ package im.vector.app.features.home.room.detail.timeline.render
|
|||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||
import org.matrix.android.sdk.api.session.events.model.getPollQuestion
|
||||
import org.matrix.android.sdk.api.session.events.model.isAudioMessage
|
||||
import org.matrix.android.sdk.api.session.events.model.isFileMessage
|
||||
|
@ -93,10 +94,13 @@ class ProcessBodyOfReplyToEventUseCase @Inject constructor(
|
|||
)
|
||||
}
|
||||
repliedToEvent.isPoll() -> {
|
||||
val fallbackText = if (repliedToEvent.type in EventType.POLL_START.values)
|
||||
stringProvider.getString(R.string.message_reply_to_sender_created_poll)
|
||||
else stringProvider.getString(R.string.message_reply_to_sender_ended_poll)
|
||||
matrixFormattedBody.replaceRange(
|
||||
afterBreakingLineIndex,
|
||||
endOfBlockQuoteIndex,
|
||||
repliedToEvent.getPollQuestion() ?: stringProvider.getString(R.string.message_reply_to_sender_created_poll)
|
||||
repliedToEvent.getPollQuestion() ?: fallbackText
|
||||
)
|
||||
}
|
||||
repliedToEvent.isLiveLocation() -> {
|
||||
|
|
|
@ -78,6 +78,7 @@ class CheckIfCanReplyEventUseCaseTest {
|
|||
MessageType.MSGTYPE_AUDIO,
|
||||
MessageType.MSGTYPE_FILE,
|
||||
MessageType.MSGTYPE_POLL_START,
|
||||
MessageType.MSGTYPE_POLL_END,
|
||||
MessageType.MSGTYPE_BEACON_INFO,
|
||||
MessageType.MSGTYPE_LOCATION
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue