Prevent reply to poll local echo (relation to echo not supported yet)

This commit is contained in:
Valere 2020-09-03 11:07:28 +02:00 committed by Benoit Marty
parent eb5088c699
commit c895f87e26
3 changed files with 7 additions and 2 deletions

View file

@ -347,7 +347,7 @@ internal class EventRelationsAggregationProcessor @Inject constructor(@UserId pr
if (userId == senderId) {
sumModel.myVote = optionIndex
}
Timber.v("## POLL adding vote $optionIndex for user $senderId in poll :$relatedEventId ")
Timber.v("## POLL adding vote $optionIndex for user $senderId in poll :$targetEventId ")
} else {
Timber.v("## POLL Ignoring vote (older than known one) eventId:$eventId ")
}
@ -356,7 +356,7 @@ internal class EventRelationsAggregationProcessor @Inject constructor(@UserId pr
if (userId == senderId) {
sumModel.myVote = optionIndex
}
Timber.v("## POLL adding vote $optionIndex for user $senderId in poll :$relatedEventId ")
Timber.v("## POLL adding vote $optionIndex for user $senderId in poll :$targetEventId ")
}
sumModel.votes = votes
if (isLocalEcho) {

View file

@ -63,6 +63,7 @@ import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.api.session.events.model.isAttachmentMessage
import org.matrix.android.sdk.api.session.events.model.LocalEcho
import org.matrix.android.sdk.api.session.events.model.isTextMessage
import org.matrix.android.sdk.api.session.events.model.toContent
import org.matrix.android.sdk.api.session.events.model.toModel
@ -1218,6 +1219,8 @@ class RoomDetailViewModel @AssistedInject constructor(
}
private fun handleReplyToOptions(action: RoomDetailAction.ReplyToOptions) {
// Do not allow to reply to unsent local echo
if (LocalEcho.isLocalEchoId(action.eventId)) return
room.sendOptionsReply(action.eventId, action.optionIndex, action.optionValue)
}

View file

@ -75,6 +75,8 @@ abstract class MessagePollItem : AbsMessageItem<MessagePollItem.Holder>() {
optionsContent?.options?.forEachIndexed { index, item ->
if (index < buttons.size) {
buttons[index].let {
// current limitation, have to wait for event to be sent in order to reply
it.isEnabled = informationData?.sendState?.isSent() ?: false
it.text = item.label
it.isVisible = true
}