Setup Assistant: Drop debounce function

The checkBlenderExePath function is now executed only once the Next
button is pressed. This is the same behavior as for the storage
selection step.
This commit is contained in:
Francesco Siddi 2022-07-26 19:13:35 +02:00
parent 920420c10e
commit 3a0ace2122

View File

@ -99,9 +99,9 @@
<step-item <step-item
v-show="currentSetupStep == 3" v-show="currentSetupStep == 3"
@next-clicked="nextStep" @next-clicked="nextStepAfterCheckBlenderExePath"
@back-clicked="prevStep" @back-clicked="prevStep"
:is-next-clickable="selectedBlender != null && selectedBlender.is_usable" :is-next-clickable="selectedBlender != null || customBlenderExe != (null || '')"
title="Blender" title="Blender"
> >
@ -178,8 +178,9 @@
</div> </div>
<div> <div>
<input <input
@input="checkBlenderExePath"
v-model="customBlenderExe" v-model="customBlenderExe"
@keyup.enter="nextStepAfterCheckBlenderExePath"
@focus="selectedBlender = null"
:class="{'is-invalid': blenderExeCheckResult != null && !blenderExeCheckResult.is_usable}" :class="{'is-invalid': blenderExeCheckResult != null && !blenderExeCheckResult.is_usable}"
type="text" type="text"
placeholder="Path to Blender" placeholder="Path to Blender"
@ -193,8 +194,8 @@
<div v-if="autoFoundBlenders.length === 0"> <div v-if="autoFoundBlenders.length === 0">
<input <input
@input="checkBlenderExePath"
v-model="customBlenderExe" v-model="customBlenderExe"
@keyup.enter="nextStepAfterCheckBlenderExePath"
:class="{'is-invalid': blenderExeCheckResult != null && !blenderExeCheckResult.is_usable}" :class="{'is-invalid': blenderExeCheckResult != null && !blenderExeCheckResult.is_usable}"
type="text" type="text"
placeholder="Path to Blender executable" placeholder="Path to Blender executable"
@ -254,21 +255,6 @@ import StepItem from '@/components/steps/StepItem.vue';
import { MetaApi, PathCheckInput, SetupAssistantConfig } from "@/manager-api"; import { MetaApi, PathCheckInput, SetupAssistantConfig } from "@/manager-api";
import { apiClient } from '@/stores/api-query-count'; import { apiClient } from '@/stores/api-query-count';
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
}
export default { export default {
name: 'SetupAssistantView', name: 'SetupAssistantView',
components: { components: {
@ -362,6 +348,13 @@ export default {
}) })
}, },
nextStepAfterCheckBlenderExePath() {
this.checkBlenderExePath();
if (this.selectedBlender != null && this.selectedBlender.is_usable) {
this.nextStep();
}
},
findBlenderExePath() { findBlenderExePath() {
this.isBlenderExeFinding = true; this.isBlenderExeFinding = true;
this.autoFoundBlenders = []; this.autoFoundBlenders = [];
@ -462,9 +455,6 @@ export default {
}) })
}, },
}, },
created() {
this.checkBlenderExePath = debounce(this.checkBlenderExePath, 200)
}
} }
</script> </script>
<style> <style>