Do not send edition if text is identical

This commit is contained in:
Benoit Marty 2019-07-10 16:32:44 +02:00
parent d613abf4b4
commit 7e8cd07e1e
1 changed files with 12 additions and 3 deletions

View File

@ -232,8 +232,17 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
}
}
SendMode.EDIT -> {
room.editTextMessage(state.selectedEvent?.root?.eventId
?: "", action.text, action.autoMarkdown)
val messageContent: MessageContent? =
state.selectedEvent?.annotations?.editSummary?.aggregatedContent.toModel()
?: state.selectedEvent?.root?.getClearContent().toModel()
val nonFormattedBody = messageContent?.body ?: ""
if (nonFormattedBody != action.text) {
room.editTextMessage(state.selectedEvent?.root?.eventId
?: "", action.text, action.autoMarkdown)
} else {
Timber.w("Same message content, do not send edition")
}
setState {
copy(
sendMode = SendMode.REGULAR,
@ -244,7 +253,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
}
SendMode.QUOTE -> {
val messageContent: MessageContent? =
state.selectedEvent?.annotations?.editSummary?.aggregatedContent?.toModel()
state.selectedEvent?.annotations?.editSummary?.aggregatedContent.toModel()
?: state.selectedEvent?.root?.getClearContent().toModel()
val textMsg = messageContent?.body