Browse Source

disable buttons while waiting for response

avoids doubleclick and doubled data

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Marcel Hibbe 2 years ago
parent
commit
58739b8f14

+ 2 - 0
app/src/main/java/com/nextcloud/talk/polls/viewmodels/PollCreateViewModel.kt

@@ -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

+ 2 - 0
app/src/main/java/com/nextcloud/talk/polls/viewmodels/PollVoteViewModel.kt

@@ -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())