mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-15 01:35:07 +08:00
Do not allow to vote the same option twice.
This commit is contained in:
parent
d5f8931e20
commit
be9e592aa5
@ -158,7 +158,7 @@ internal class LocalEchoEventFactory @Inject constructor(
|
||||
),
|
||||
answers = options.mapIndexed { index, option ->
|
||||
PollAnswer(
|
||||
id = index.toString(),
|
||||
id = "$index-$option",
|
||||
answer = option
|
||||
)
|
||||
}
|
||||
|
@ -911,7 +911,13 @@ class RoomDetailViewModel @AssistedInject constructor(
|
||||
private fun handleVoteToPoll(action: RoomDetailAction.VoteToPoll) {
|
||||
// Do not allow to vote unsent local echo of the poll event
|
||||
if (LocalEcho.isLocalEchoId(action.eventId)) return
|
||||
room.voteToPoll(action.eventId, action.optionKey)
|
||||
// Do not allow to vote the same option twice
|
||||
room.getTimeLineEvent(action.eventId)?.let { pollTimelineEvent ->
|
||||
val currentVote = pollTimelineEvent.annotations?.pollResponseSummary?.aggregatedContent?.myVote
|
||||
if (currentVote != action.optionKey) {
|
||||
room.voteToPoll(action.eventId, action.optionKey)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleEndPoll(eventId: String) {
|
||||
|
Loading…
Reference in New Issue
Block a user