From 69efd9e09d043403c987a5ab7fddd68158a1d22a Mon Sep 17 00:00:00 2001 From: Stixx Date: Fri, 6 Dec 2024 15:49:57 +0100 Subject: [PATCH 1/5] fix: clicking logo not redirecting to home --- src/components/AppBar/AppBar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/AppBar/AppBar.tsx b/src/components/AppBar/AppBar.tsx index a4f653e..e7f5d95 100644 --- a/src/components/AppBar/AppBar.tsx +++ b/src/components/AppBar/AppBar.tsx @@ -125,7 +125,7 @@ export const AppBar = () => { src="/logo.svg" alt="Logo" onClick={() => { - if (window.location.pathname === '/') { + if (['', '#/'].includes(window.location.hash)) { location.reload() } else { navigate('/') From 0fd0f26fc7ef87aea7c48ccddae822d23d2b8853 Mon Sep 17 00:00:00 2001 From: Stixx Date: Fri, 6 Dec 2024 16:22:23 +0100 Subject: [PATCH 2/5] fix: counterpart search NIP05 glitching --- src/pages/create/index.tsx | 41 ++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/pages/create/index.tsx b/src/pages/create/index.tsx index 212f7bf..dfe3338 100644 --- a/src/pages/create/index.tsx +++ b/src/pages/create/index.tsx @@ -148,6 +148,17 @@ export const CreatePage = () => { [setUserInput] ) + const handleSearchUserNip05 = async ( + nip05: string + ): Promise => { + const { pubkey } = await queryNip05(nip05).catch((err) => { + console.error(err) + return { pubkey: null } + }) + + return pubkey + } + const handleSearchUsers = async (searchValue?: string) => { const searchString = searchValue || userSearchInput || undefined @@ -224,7 +235,9 @@ export const CreatePage = () => { }) }, [foundUsers]) - const handleInputKeyDown = (event: React.KeyboardEvent) => { + const handleInputKeyDown = async ( + event: React.KeyboardEvent + ) => { if ( event.code === KeyboardCode.Enter || event.code === KeyboardCode.NumpadEnter @@ -238,7 +251,18 @@ export const CreatePage = () => { } else { // Otherwize if search already provided some results, user must manually click the search button if (!foundUsers.length) { - handleSearchUsers() + // If it's NIP05 send request to .well-known + if (userSearchInput.includes('@')) { + const pubkey = await handleSearchUserNip05(userSearchInput) + + if (pubkey) { + setUserInput(userSearchInput) + } else { + toast.error(`No user found with the NIP05: ${userSearchInput}`) + } + } else { + handleSearchUsers() + } } } } @@ -959,19 +983,6 @@ export const CreatePage = () => { } else { disarmAddOnEnter() } - } else if (value.includes('@')) { - // Seems like it's nip05 format - const { pubkey } = await queryNip05(value).catch((err) => { - console.error(err) - return { pubkey: null } - }) - - if (pubkey) { - // Arm the manual user npub add after enter is hit, we don't want to trigger search - setPastedUserNpubOrNip05(hexToNpub(pubkey)) - } else { - disarmAddOnEnter() - } } else { // Disarm the add user on enter hit, and trigger search after 1 second disarmAddOnEnter() From 7b29d7055eeb6bf7f9bbcc06fb2ecf0962157046 Mon Sep 17 00:00:00 2001 From: Stixx Date: Fri, 6 Dec 2024 20:58:20 +0100 Subject: [PATCH 3/5] fix: search counterparts nip05 does not need to include '@' --- src/pages/create/index.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pages/create/index.tsx b/src/pages/create/index.tsx index dfe3338..1defde7 100644 --- a/src/pages/create/index.tsx +++ b/src/pages/create/index.tsx @@ -251,10 +251,15 @@ export const CreatePage = () => { } else { // Otherwize if search already provided some results, user must manually click the search button if (!foundUsers.length) { - // If it's NIP05 send request to .well-known - if (userSearchInput.includes('@')) { + // If it's NIP05 (includes @ or is a valid domain) send request to .well-known + const domainRegex = /^[a-zA-Z0-9@.-]+\.[a-zA-Z]{2,}$/ + if (domainRegex.test(userSearchInput)) { + setSearchUsersLoading(true) + const pubkey = await handleSearchUserNip05(userSearchInput) + setSearchUsersLoading(false) + if (pubkey) { setUserInput(userSearchInput) } else { From afbe05b4c88d5042c17f4a59c0739dc8942642a9 Mon Sep 17 00:00:00 2001 From: Stixx Date: Fri, 6 Dec 2024 21:00:52 +0100 Subject: [PATCH 4/5] fix: footer 'Home' button scroll to top when on home page, fixed logic --- src/components/Footer/Footer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Footer/Footer.tsx b/src/components/Footer/Footer.tsx index 249b8c4..c7459e3 100644 --- a/src/components/Footer/Footer.tsx +++ b/src/components/Footer/Footer.tsx @@ -69,7 +69,7 @@ export const Footer = () => component={Link} to={'/'} onClick={(event) => { - if (window.location.pathname === '/') { + if (['', '#/'].includes(window.location.hash)) { event.preventDefault() window.scrollTo(0, 0) } From 99fa3add562c4efa013954c0e0df95723b9aea3d Mon Sep 17 00:00:00 2001 From: Stixx Date: Tue, 10 Dec 2024 15:29:24 +0100 Subject: [PATCH 5/5] fix: bug, when valid npub, clicking + was saying npub was invalid --- src/pages/create/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/create/index.tsx b/src/pages/create/index.tsx index 1defde7..0ce990f 100644 --- a/src/pages/create/index.tsx +++ b/src/pages/create/index.tsx @@ -1162,7 +1162,9 @@ export const CreatePage = () => { ) : (