From 7400e007965664e46b28625e68d06ed267d4883f Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 8 May 2023 20:15:10 +0200 Subject: [PATCH] Make UrlDuplicate warning more responsive --- src/components/BotLogin.vue | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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; };