Fix issue when quoting event in e2e rooms (Fixes #295)

This commit is contained in:
Benoit Marty 2019-07-04 12:39:59 +02:00
parent a79a6443e7
commit 9d0c50907c
3 changed files with 18 additions and 18 deletions

View File

@ -42,7 +42,7 @@ interface SendService {
* @param formattedText The formatted body using MessageType#FORMAT_MATRIX_HTML
* @return a [Cancelable]
*/
fun sendFormattedTextMessage(text: String,formattedText: String): Cancelable
fun sendFormattedTextMessage(text: String, formattedText: String): Cancelable
/**
* Method to send a media asynchronously.

View File

@ -54,6 +54,19 @@ internal class DefaultSendService @Inject constructor(private val context: Conte
val event = localEchoEventFactory.createTextEvent(roomId, msgType, text, autoMarkdown).also {
saveLocalEcho(it)
}
return sendEvent(event)
}
override fun sendFormattedTextMessage(text: String, formattedText: String): Cancelable {
val event = localEchoEventFactory.createFormattedTextEvent(roomId, text, formattedText).also {
saveLocalEcho(it)
}
return sendEvent(event)
}
private fun sendEvent(event: Event): Cancelable {
// Encrypted room handling
return if (cryptoService.isRoomEncrypted(roomId)) {
Timber.v("Send event in encrypted room")
@ -62,25 +75,12 @@ internal class DefaultSendService @Inject constructor(private val context: Conte
TimelineSendEventWorkCommon.postSequentialWorks(context, roomId, encryptWork, sendWork)
CancelableWork(context, encryptWork.id)
} else {
sendEvent(event)
val sendWork = createSendEventWork(event)
TimelineSendEventWorkCommon.postWork(context, roomId, sendWork)
CancelableWork(context, sendWork.id)
}
}
private fun sendEvent(event: Event): Cancelable {
val sendWork = createSendEventWork(event)
TimelineSendEventWorkCommon.postWork(context, roomId, sendWork)
return CancelableWork(context, sendWork.id)
}
override fun sendFormattedTextMessage(text: String, formattedText: String): Cancelable {
val event = localEchoEventFactory.createFormattedTextEvent(roomId, text, formattedText).also {
saveLocalEcho(it)
}
val sendWork = createSendEventWork(event)
TimelineSendEventWorkCommon.postWork(context, roomId, sendWork)
return CancelableWork(context, sendWork.id)
}
override fun sendMedias(attachments: List<ContentAttachmentData>): Cancelable {
val cancelableBag = CancelableBag()
attachments.forEach {

View File

@ -233,7 +233,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
SendMode.QUOTE -> {
val messageContent: MessageContent? =
state.selectedEvent?.annotations?.editSummary?.aggregatedContent?.toModel()
?: state.selectedEvent?.root?.content.toModel()
?: state.selectedEvent?.root?.getClearContent().toModel()
val textMsg = messageContent?.body
val finalText = legacyRiotQuoteText(textMsg, action.text)