PollHistory : simplify so we only have one Node. Also enrich PollHistoryState.
This commit is contained in:
parent
4a2cbb1ed4
commit
aa9693126f
19 changed files with 376 additions and 255 deletions
|
|
@ -20,6 +20,16 @@ import io.element.android.libraries.matrix.api.core.EventId
|
|||
import io.element.android.libraries.matrix.api.poll.PollKind
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
/**
|
||||
* UI model for a PollContent.
|
||||
* @property eventId the event id of the poll.
|
||||
* @property question the poll question.
|
||||
* @property answerItems the list of answers.
|
||||
* @property pollKind the kind of poll.
|
||||
* @property isPollEditable whether the poll is editable.
|
||||
* @property isPollEnded whether the poll is ended.
|
||||
* @property isMine whether the poll has been created by me.
|
||||
*/
|
||||
data class PollContentState(
|
||||
val eventId: EventId?,
|
||||
val question: String,
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
package io.element.android.features.poll.api.pollcontent
|
||||
|
||||
import io.element.android.libraries.matrix.api.poll.PollAnswer
|
||||
import io.element.android.libraries.matrix.api.poll.PollKind
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
||||
fun aPollQuestion() = "What type of food should we have at the party?"
|
||||
|
|
@ -79,3 +81,25 @@ fun aPollAnswerItem(
|
|||
votesCount = votesCount,
|
||||
percentage = percentage
|
||||
)
|
||||
|
||||
fun aPollContentState(
|
||||
isMine: Boolean = false,
|
||||
isEnded: Boolean = false,
|
||||
isDisclosed: Boolean = true,
|
||||
hasVotes: Boolean = true,
|
||||
question: String = aPollQuestion(),
|
||||
pollKind: PollKind = PollKind.Disclosed,
|
||||
answerItems: ImmutableList<PollAnswerItem> = aPollAnswerItemList(
|
||||
isEnded = isEnded,
|
||||
isDisclosed = isDisclosed,
|
||||
hasVotes = hasVotes
|
||||
),
|
||||
) = PollContentState(
|
||||
eventId = null,
|
||||
question = question,
|
||||
answerItems = answerItems,
|
||||
pollKind = pollKind,
|
||||
isPollEditable = isMine && !isEnded,
|
||||
isPollEnded = isEnded,
|
||||
isMine = isMine,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue