avoids doubleclick and doubled data Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
@@ -114,6 +114,8 @@ class PollCreateViewModel @Inject constructor(private val repository: PollReposi
_options.value = _options.value?.filter { it.pollOption.isNotEmpty() } as ArrayList<PollCreateOptionItem>
if (_question.isNotEmpty() && _options.value?.isNotEmpty() == true) {
+ _viewState.value = PollCreationState(enableAddOptionButton = false, enableCreatePollButton = false)
+
repository.createPoll(
roomToken, _question, _options.value!!.map { it.pollOption }, resultMode,
maxVotes
@@ -79,6 +79,8 @@ class PollVoteViewModel @Inject constructor(private val repository: PollReposito
fun vote(roomToken: String, pollId: String) {
if (_selectedOptions.isNotEmpty()) {
+ _submitButtonEnabled.value = false
repository.vote(roomToken, pollId, _selectedOptions)
.doOnSubscribe { disposable = it }
?.subscribeOn(Schedulers.io())