Adds server side vote blocking for ended polls
This commit is contained in:
parent
2048b859c5
commit
e4ce4ab1ab
|
@ -54,7 +54,6 @@ abstract class PollItem : AbsMessageItem<PollItem.Holder>() {
|
||||||
|
|
||||||
override fun bind(holder: Holder) {
|
override fun bind(holder: Holder) {
|
||||||
super.bind(holder)
|
super.bind(holder)
|
||||||
val relatedEventId = eventId ?: return
|
|
||||||
|
|
||||||
renderSendState(holder.view, holder.questionTextView)
|
renderSendState(holder.view, holder.questionTextView)
|
||||||
|
|
||||||
|
@ -73,12 +72,20 @@ abstract class PollItem : AbsMessageItem<PollItem.Holder>() {
|
||||||
optionViewStates.forEachIndexed { index, optionViewState ->
|
optionViewStates.forEachIndexed { index, optionViewState ->
|
||||||
views.getOrNull(index)?.let {
|
views.getOrNull(index)?.let {
|
||||||
it.render(optionViewState)
|
it.render(optionViewState)
|
||||||
it.setOnClickListener {
|
it.setOnClickListener { onPollItemClick(optionViewState) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun onPollItemClick(optionViewState: PollOptionViewState) {
|
||||||
|
val relatedEventId = eventId
|
||||||
|
|
||||||
|
if (isPollActive(optionViewState) && relatedEventId != null) {
|
||||||
callback?.onTimelineItemAction(RoomDetailAction.VoteToPoll(relatedEventId, optionViewState.optionId))
|
callback?.onTimelineItemAction(RoomDetailAction.VoteToPoll(relatedEventId, optionViewState.optionId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
private fun isPollActive(optionViewState: PollOptionViewState) = optionViewState !is PollOptionViewState.PollEnded
|
||||||
|
|
||||||
class Holder : AbsMessageItem.Holder(STUB_ID) {
|
class Holder : AbsMessageItem.Holder(STUB_ID) {
|
||||||
val questionTextView by bind<TextView>(R.id.questionTextView)
|
val questionTextView by bind<TextView>(R.id.questionTextView)
|
||||||
|
|
Loading…
Reference in New Issue