disable buttons while waiting for response

avoids doubleclick and doubled data

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2022-07-20 17:49:18 +02:00 committed by Andy Scherzinger (Rebase PR Action)
parent f46d2d28f5
commit 58739b8f14
2 changed files with 4 additions and 0 deletions

View File

@ -114,6 +114,8 @@ class PollCreateViewModel @Inject constructor(private val repository: PollReposi
_options.value = _options.value?.filter { it.pollOption.isNotEmpty() } as ArrayList<PollCreateOptionItem> _options.value = _options.value?.filter { it.pollOption.isNotEmpty() } as ArrayList<PollCreateOptionItem>
if (_question.isNotEmpty() && _options.value?.isNotEmpty() == true) { if (_question.isNotEmpty() && _options.value?.isNotEmpty() == true) {
_viewState.value = PollCreationState(enableAddOptionButton = false, enableCreatePollButton = false)
repository.createPoll( repository.createPoll(
roomToken, _question, _options.value!!.map { it.pollOption }, resultMode, roomToken, _question, _options.value!!.map { it.pollOption }, resultMode,
maxVotes maxVotes

View File

@ -79,6 +79,8 @@ class PollVoteViewModel @Inject constructor(private val repository: PollReposito
fun vote(roomToken: String, pollId: String) { fun vote(roomToken: String, pollId: String) {
if (_selectedOptions.isNotEmpty()) { if (_selectedOptions.isNotEmpty()) {
_submitButtonEnabled.value = false
repository.vote(roomToken, pollId, _selectedOptions) repository.vote(roomToken, pollId, _selectedOptions)
.doOnSubscribe { disposable = it } .doOnSubscribe { disposable = it }
?.subscribeOn(Schedulers.io()) ?.subscribeOn(Schedulers.io())