Add ability to cancel a pending vote.

This commit is contained in:
Michelle Tang
2025-10-16 11:32:40 -04:00
committed by Cody Henthorne
parent 08eca9ac27
commit 91b70038e6
13 changed files with 413 additions and 156 deletions

View File

@@ -11,6 +11,5 @@ data class PollOption(
val id: Long,
val text: String,
val voters: List<Voter>,
val isSelected: Boolean = false,
val isPending: Boolean = false
val voteState: VoteState = VoteState.NONE
) : Parcelable

View File

@@ -0,0 +1,27 @@
package org.thoughtcrime.securesms.polls
/**
* Tracks general state information when a user votes in a poll. Vote states are specific to an option in a poll
* eg. in a poll with three options, each option can have a different states like (PENDING_ADD, ADDED, NONE)
*/
enum class VoteState(val value: Int) {
/** We have no information on the vote state */
NONE(0),
/** Vote is in the process of being removed */
PENDING_REMOVE(1),
/** Vote is in the process of being added */
PENDING_ADD(2),
/** Vote was removed */
REMOVED(3),
/** Vote was added */
ADDED(4);
companion object {
fun fromValue(value: Int) = VoteState.entries.first { it.value == value }
}
}