diff --git a/src/components/BotLogin.vue b/src/components/BotLogin.vue index 6ac4f940..c220046b 100644 --- a/src/components/BotLogin.vue +++ b/src/components/BotLogin.vue @@ -86,7 +86,7 @@ import { useUserService } from '@/shared/userService'; import { AuthPayload, AuthStorageWithBotId } from '@/types'; -import { ref } from 'vue'; +import { computed, ref } from 'vue'; import { useBotStore } from '@/stores/ftbotwrapper'; import { useRoute, useRouter } from 'vue-router'; import axios from 'axios'; @@ -106,7 +106,6 @@ const botStore = useBotStore(); const nameState = ref(''); const pwdState = ref(''); const urlState = ref(''); -const urlDuplicate = ref(false); const errorMessage = ref(''); const errorMessageCORS = ref(false); const formRef = ref(); @@ -122,15 +121,16 @@ const emitLoginResult = (value: boolean) => { emit('loginResult', value); }; +const urlDuplicate = computed(() => { + const bots = Object.values(botStore.availableBots).find((bot) => bot.botUrl === auth.value.url); + return bots !== undefined; +}); + const checkFormValidity = () => { const valid = formRef.value?.checkValidity(); nameState.value = valid || auth.value.username !== ''; pwdState.value = valid || auth.value.password !== ''; urlState.value = valid || auth.value.url !== ''; - if (urlState.value) { - const bots = Object.values(botStore.availableBots).find((bot) => bot.botUrl === auth.value.url); - urlDuplicate.value = bots !== undefined; - } return valid; }; @@ -142,7 +142,6 @@ const resetLogin = () => { nameState.value = ''; pwdState.value = ''; urlState.value = ''; - urlDuplicate.value = false; errorMessage.value = ''; botEdit.value = false; };