mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
Do not allow to vote the same option twice.
This commit is contained in:
parent
d5f8931e20
commit
be9e592aa5
2 changed files with 8 additions and 2 deletions
|
@ -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 a new issue