mirror of
https://github.com/element-hq/element-android
synced 2024-11-23 09:55:40 +03:00
Send emote
This commit is contained in:
parent
eaff5ac9f0
commit
6248cc5552
4 changed files with 12 additions and 8 deletions
|
@ -18,6 +18,7 @@ package im.vector.matrix.android.api.session.room.send
|
|||
|
||||
import im.vector.matrix.android.api.MatrixCallback
|
||||
import im.vector.matrix.android.api.session.events.model.Event
|
||||
import im.vector.matrix.android.api.session.room.model.message.MessageType
|
||||
import im.vector.matrix.android.api.util.Cancelable
|
||||
|
||||
/**
|
||||
|
@ -28,10 +29,13 @@ interface SendService {
|
|||
/**
|
||||
* Method to send a text message asynchronously.
|
||||
* @param text the text message to send
|
||||
* @param msgType the message type: MessageType.MSGTYPE_TEXT (default) or MessageType.MSGTYPE_EMOTE
|
||||
* @param callback the callback to be notified.
|
||||
* @return a [Cancelable]
|
||||
*/
|
||||
fun sendTextMessage(text: String, callback: MatrixCallback<Event>): Cancelable
|
||||
fun sendTextMessage(text: String,
|
||||
msgType: String = MessageType.MSGTYPE_TEXT,
|
||||
callback: MatrixCallback<Event>): Cancelable
|
||||
|
||||
|
||||
}
|
|
@ -42,8 +42,8 @@ internal class DefaultSendService(private val roomId: String,
|
|||
.build()
|
||||
|
||||
// TODO callback is not used
|
||||
override fun sendTextMessage(text: String, callback: MatrixCallback<Event>): Cancelable {
|
||||
val event = eventFactory.createTextEvent(roomId, text)
|
||||
override fun sendTextMessage(text: String, msgType: String, callback: MatrixCallback<Event>): Cancelable {
|
||||
val event = eventFactory.createTextEvent(roomId, msgType, text)
|
||||
|
||||
monarchy.tryTransactionAsync { realm ->
|
||||
val chunkEntity = ChunkEntity.findLastLiveChunkFromRoom(realm, roomId)
|
||||
|
|
|
@ -21,15 +21,14 @@ import im.vector.matrix.android.api.session.events.model.Content
|
|||
import im.vector.matrix.android.api.session.events.model.Event
|
||||
import im.vector.matrix.android.api.session.events.model.EventType
|
||||
import im.vector.matrix.android.api.session.room.model.message.MessageTextContent
|
||||
import im.vector.matrix.android.api.session.room.model.message.MessageType
|
||||
import im.vector.matrix.android.internal.di.MoshiProvider
|
||||
|
||||
internal class EventFactory(private val credentials: Credentials) {
|
||||
|
||||
private val moshi = MoshiProvider.providesMoshi()
|
||||
|
||||
fun createTextEvent(roomId: String, text: String): Event {
|
||||
val content = MessageTextContent(type = MessageType.MSGTYPE_TEXT, body = text)
|
||||
fun createTextEvent(roomId: String, msgType: String, text: String): Event {
|
||||
val content = MessageTextContent(type = msgType, body = text)
|
||||
|
||||
return Event(
|
||||
roomId = roomId,
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.jakewharton.rxrelay2.BehaviorRelay
|
|||
import im.vector.matrix.android.api.MatrixCallback
|
||||
import im.vector.matrix.android.api.session.Session
|
||||
import im.vector.matrix.android.api.session.events.model.Event
|
||||
import im.vector.matrix.android.api.session.room.model.message.MessageType
|
||||
import im.vector.matrix.rx.rx
|
||||
import im.vector.riotredesign.core.platform.VectorViewModel
|
||||
import im.vector.riotredesign.core.utils.LiveEvent
|
||||
|
@ -136,8 +137,8 @@ class RoomDetailViewModel(initialState: RoomDetailViewState,
|
|||
_sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandNotImplemented))
|
||||
}
|
||||
is ParsedCommand.SendEmote -> {
|
||||
// TODO
|
||||
_sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandNotImplemented))
|
||||
room.sendTextMessage(slashCommandResult.message, msgType = MessageType.MSGTYPE_EMOTE, callback = object : MatrixCallback<Event> {})
|
||||
_sendMessageResultLiveData.postValue(LiveEvent(SendMessageResult.SlashCommandHandled))
|
||||
}
|
||||
is ParsedCommand.ChangeTopic -> {
|
||||
// TODO
|
||||
|
|
Loading…
Reference in a new issue