/confetti /snow commands: send emote if text is blank (iso Element Web)
This commit is contained in:
parent
6ddcd046d4
commit
bb9a08d429
|
@ -113,6 +113,7 @@ class ChatEffectManager @Inject constructor() {
|
|||
return when (content.msgType) {
|
||||
MessageType.MSGTYPE_CONFETTI -> ChatEffect.CONFETTI
|
||||
MessageType.MSGTYPE_SNOW -> ChatEffect.SNOW
|
||||
MessageType.MSGTYPE_EMOTE,
|
||||
MessageType.MSGTYPE_TEXT -> {
|
||||
event.root.getClearContent().toModel<MessageContent>()?.body
|
||||
?.let { text ->
|
||||
|
|
|
@ -716,7 +716,7 @@ class RoomDetailViewModel @AssistedInject constructor(
|
|||
popDraft()
|
||||
}
|
||||
is ParsedCommand.SendChatEffect -> {
|
||||
room.sendTextMessage(slashCommandResult.message, slashCommandResult.chatEffect.toMessageType())
|
||||
sendChatEffect(slashCommandResult)
|
||||
_viewEvents.post(RoomDetailViewEvents.SlashCommandHandled())
|
||||
popDraft()
|
||||
}
|
||||
|
@ -808,6 +808,19 @@ class RoomDetailViewModel @AssistedInject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun sendChatEffect(sendChatEffect: ParsedCommand.SendChatEffect) {
|
||||
// If message is blank, convert to an emote, with default message
|
||||
if (sendChatEffect.message.isBlank()) {
|
||||
val defaultMessage = stringProvider.getString(when (sendChatEffect.chatEffect) {
|
||||
ChatEffect.CONFETTI -> R.string.default_message_emote_confetti
|
||||
ChatEffect.SNOW -> R.string.default_message_emote_snow
|
||||
})
|
||||
room.sendTextMessage(defaultMessage, MessageType.MSGTYPE_EMOTE)
|
||||
} else {
|
||||
room.sendTextMessage(sendChatEffect.message, sendChatEffect.chatEffect.toMessageType())
|
||||
}
|
||||
}
|
||||
|
||||
private fun popDraft() = withState {
|
||||
if (it.sendMode is SendMode.REGULAR && it.sendMode.fromSharing) {
|
||||
// If we were sharing, we want to get back our last value from draft
|
||||
|
|
|
@ -2572,6 +2572,10 @@
|
|||
|
||||
<string name="command_confetti">Sends the given message with confetti</string>
|
||||
<string name="command_snow">Sends the given message with snow</string>
|
||||
<!-- Note to translator: please use the same emoji 🎉 in your translation -->
|
||||
<string name="default_message_emote_confetti">sends confetti 🎉</string>
|
||||
<!-- Note to translator: please use the same emoji ❄️ in your translation -->
|
||||
<string name="default_message_emote_snow">sends snow ❄️</string>
|
||||
|
||||
<string name="unencrypted">Unencrypted</string>
|
||||
<string name="encrypted_unverified">Encrypted by an unverified device</string>
|
||||
|
|
Loading…
Reference in New Issue