From 5e80f5056d0e839c72560388c7ce33b33726033d Mon Sep 17 00:00:00 2001 From: Hariom Balhara Date: Thu, 29 Sep 2022 21:35:01 +0530 Subject: [PATCH] Ensure currentUsername is set before comparing it with username (#4750) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Omar López Co-authored-by: Alan Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../components/ui/UsernameAvailability/PremiumTextfield.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/web/components/ui/UsernameAvailability/PremiumTextfield.tsx b/apps/web/components/ui/UsernameAvailability/PremiumTextfield.tsx index 9c02a5555d..dc38ecce3d 100644 --- a/apps/web/components/ui/UsernameAvailability/PremiumTextfield.tsx +++ b/apps/web/components/ui/UsernameAvailability/PremiumTextfield.tsx @@ -91,11 +91,10 @@ const PremiumTextfield = (props: ICustomUsernameProps) => { const isCurrentUsernamePremium = user && user.metadata && hasKeyInMetadata(user, "isPremium") ? !!user.metadata.isPremium : false; const [isInputUsernamePremium, setIsInputUsernamePremium] = useState(false); - const debouncedApiCall = useCallback( - debounce(async (username) => { + debounce(async (username: string) => { const { data } = await fetchUsername(username); - setMarkAsError(!data.available && username && username !== currentUsername); + setMarkAsError(!data.available && !!currentUsername && username !== currentUsername); setIsInputUsernamePremium(data.premium); setUsernameIsAvailable(data.available); }, 150),