From 32e83830ca384ba141c0cc711d7fa7de77e7a14a Mon Sep 17 00:00:00 2001 From: Dmytro Svyrydenko Date: Mon, 8 Jan 2024 15:13:59 +0200 Subject: [PATCH 1/3] fix: broken search field --- src/screens/SearchResult.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/screens/SearchResult.tsx b/src/screens/SearchResult.tsx index a564865..3339e84 100644 --- a/src/screens/SearchResult.tsx +++ b/src/screens/SearchResult.tsx @@ -67,7 +67,7 @@ export const SearchResult = ({ setSearch(newText.toLowerCase())} + onChangeText={(newText) => setInput(newText.toLowerCase())} value={input} placeholder={t`Search for a domain`} type="search" @@ -113,7 +113,9 @@ export const SearchResult = ({ )} - {!results.loading && results.result && suggestions.loading ? ( + {!results.loading && + results.result?.length && + suggestions.loading ? ( <> Date: Mon, 8 Jan 2024 15:15:29 +0200 Subject: [PATCH 2/3] chore: improve code readability --- src/screens/SearchResult.tsx | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/screens/SearchResult.tsx b/src/screens/SearchResult.tsx index 3339e84..985a8ec 100644 --- a/src/screens/SearchResult.tsx +++ b/src/screens/SearchResult.tsx @@ -27,12 +27,17 @@ export const SearchResult = ({ const connection = useSolanaConnection(); const { currentModal } = useModal(); const { setStatus } = useStatusModalContext(); - const [search, setSearch] = useState(domain || ""); - const [input, setInput] = useState(domain || ""); - const results = useSearch({ connection: connection!, domain: search }); + const [activeSearchQuery, setSearchQuery] = useState(domain || ""); + // "inputFieldValue" is only responsible for what is displayed in input field, data + // is loaded based on "activeSearchQuery" + const [inputFieldValue, setInput] = useState(domain || ""); + const results = useSearch({ + connection: connection!, + domain: activeSearchQuery, + }); const suggestions = useDomainSuggestions({ connection: connection!, - domain: search, + domain: activeSearchQuery, }); const navigation = useNavigation(); const isFocused = useIsFocused(); @@ -40,26 +45,26 @@ export const SearchResult = ({ const [showPopularDomains, togglePopularDomains] = useState(loadPopular); useEffect(() => { - setSearch(domain || search); - setInput(domain || search); + setSearchQuery(domain || activeSearchQuery); + setInput(domain || activeSearchQuery); }, [domain, isFocused]); const handle = async () => { - if (!input) return; + if (!inputFieldValue) return; togglePopularDomains(false); - if (isPubkey(input)) { + if (isPubkey(inputFieldValue)) { return navigation.navigate("Home", { screen: "search-profile", - params: { owner: input }, + params: { owner: inputFieldValue }, }); } - if (!validate(input)) { + if (!validate(inputFieldValue)) { return setStatus({ status: "error", - message: t`${input}.sol is not a valid domain`, + message: t`${inputFieldValue}.sol is not a valid domain`, }); } - setSearch(trimTld(input)); + setSearchQuery(trimTld(inputFieldValue)); }; return ( @@ -68,7 +73,7 @@ export const SearchResult = ({ setInput(newText.toLowerCase())} - value={input} + value={inputFieldValue} placeholder={t`Search for a domain`} type="search" editable={currentModal !== "Error"} @@ -81,7 +86,7 @@ export const SearchResult = ({ From 1707783d9d87bf4c7d455e47b97c565420e4ac84 Mon Sep 17 00:00:00 2001 From: Dmytro Svyrydenko Date: Mon, 8 Jan 2024 16:14:27 +0200 Subject: [PATCH 3/3] feat: update i18n --- src/locales/en/messages.po | 10 +++++++--- src/locales/es/messages.po | 12 ++++++++---- src/locales/fr/messages.po | 12 ++++++++---- src/locales/kr/messages.po | 12 ++++++++---- src/locales/tr/messages.po | 12 ++++++++---- src/locales/zh-Hans/messages.po | 12 ++++++++---- 6 files changed, 47 insertions(+), 23 deletions(-) diff --git a/src/locales/en/messages.po b/src/locales/en/messages.po index fd83434..4654381 100644 --- a/src/locales/en/messages.po +++ b/src/locales/en/messages.po @@ -26,7 +26,11 @@ msgid "{domain}.sol successfully transfered!" msgstr "" #: src/screens/SearchResult.tsx:59 -msgid "{input}.sol is not a valid domain" +#~ msgid "{input}.sol is not a valid domain" +#~ msgstr "" + +#: src/screens/SearchResult.tsx:64 +msgid "{inputFieldValue}.sol is not a valid domain" msgstr "" #: src/screens/HomeScreen.tsx:54 @@ -577,7 +581,7 @@ msgstr "" #: src/screens/HomeScreen.tsx:95 #: src/screens/Profile/index.tsx:193 -#: src/screens/SearchResult.tsx:72 +#: src/screens/SearchResult.tsx:77 msgid "Search for a domain" msgstr "" @@ -587,7 +591,7 @@ msgstr "" #~ msgstr "" #: src/screens/HomeScreen.tsx:107 -#: src/screens/SearchResult.tsx:85 +#: src/screens/SearchResult.tsx:90 msgid "Search your .SOL domain" msgstr "" diff --git a/src/locales/es/messages.po b/src/locales/es/messages.po index 2b8bc3b..2bb541b 100644 --- a/src/locales/es/messages.po +++ b/src/locales/es/messages.po @@ -28,8 +28,12 @@ msgid "{domain}.sol successfully transfered!" msgstr "{dominio}.sol ¡transferido con éxito! ?" #: src/screens/SearchResult.tsx:59 -msgid "{input}.sol is not a valid domain" -msgstr "{input}.sol no es un dominio válido" +#~ msgid "{input}.sol is not a valid domain" +#~ msgstr "{input}.sol no es un dominio válido" + +#: src/screens/SearchResult.tsx:64 +msgid "{inputFieldValue}.sol is not a valid domain" +msgstr "" #: src/screens/HomeScreen.tsx:54 msgid "{search}.sol is not a valid domain" @@ -477,12 +481,12 @@ msgstr "Buscar dominios" #: src/screens/HomeScreen.tsx:95 #: src/screens/Profile/index.tsx:193 -#: src/screens/SearchResult.tsx:72 +#: src/screens/SearchResult.tsx:77 msgid "Search for a domain" msgstr "Buscar un dominio" #: src/screens/HomeScreen.tsx:107 -#: src/screens/SearchResult.tsx:85 +#: src/screens/SearchResult.tsx:90 msgid "Search your .SOL domain" msgstr "Busca tu dominio .SOL" diff --git a/src/locales/fr/messages.po b/src/locales/fr/messages.po index 829b862..776a2a2 100644 --- a/src/locales/fr/messages.po +++ b/src/locales/fr/messages.po @@ -28,8 +28,12 @@ msgid "{domain}.sol successfully transfered!" msgstr "Transfert réussi !" #: src/screens/SearchResult.tsx:59 -msgid "{input}.sol is not a valid domain" -msgstr "{input}.sol n'est pas un domaine valide." +#~ msgid "{input}.sol is not a valid domain" +#~ msgstr "{input}.sol n'est pas un domaine valide." + +#: src/screens/SearchResult.tsx:64 +msgid "{inputFieldValue}.sol is not a valid domain" +msgstr "" #: src/screens/HomeScreen.tsx:54 msgid "{search}.sol is not a valid domain" @@ -503,12 +507,12 @@ msgstr "Recherchez des domains" #: src/screens/HomeScreen.tsx:95 #: src/screens/Profile/index.tsx:193 -#: src/screens/SearchResult.tsx:72 +#: src/screens/SearchResult.tsx:77 msgid "Search for a domain" msgstr "Recherchez un domaine" #: src/screens/HomeScreen.tsx:107 -#: src/screens/SearchResult.tsx:85 +#: src/screens/SearchResult.tsx:90 msgid "Search your .SOL domain" msgstr "Recherchez votre domaine .SOL" diff --git a/src/locales/kr/messages.po b/src/locales/kr/messages.po index bbe339d..6b15f4e 100644 --- a/src/locales/kr/messages.po +++ b/src/locales/kr/messages.po @@ -28,8 +28,12 @@ msgid "{domain}.sol successfully transfered!" msgstr "{domain}.sol이 성공적으로 전송되었습니다!" #: src/screens/SearchResult.tsx:59 -msgid "{input}.sol is not a valid domain" -msgstr "{input}.sol은(는) 유효한 도메인이 아닙니다" +#~ msgid "{input}.sol is not a valid domain" +#~ msgstr "{input}.sol은(는) 유효한 도메인이 아닙니다" + +#: src/screens/SearchResult.tsx:64 +msgid "{inputFieldValue}.sol is not a valid domain" +msgstr "" #: src/screens/HomeScreen.tsx:54 msgid "{search}.sol is not a valid domain" @@ -585,7 +589,7 @@ msgstr "도메인 검색" #: src/screens/HomeScreen.tsx:95 #: src/screens/Profile/index.tsx:193 -#: src/screens/SearchResult.tsx:72 +#: src/screens/SearchResult.tsx:77 msgid "Search for a domain" msgstr "도메인을 검색하기" @@ -595,7 +599,7 @@ msgstr "도메인을 검색하기" #~ msgstr "당신의 이름.sol을 검색하세요" #: src/screens/HomeScreen.tsx:107 -#: src/screens/SearchResult.tsx:85 +#: src/screens/SearchResult.tsx:90 msgid "Search your .SOL domain" msgstr "당신의 SOL 도메인 검색하기" diff --git a/src/locales/tr/messages.po b/src/locales/tr/messages.po index 57e68ea..f645ac3 100644 --- a/src/locales/tr/messages.po +++ b/src/locales/tr/messages.po @@ -28,8 +28,12 @@ msgid "{domain}.sol successfully transfered!" msgstr "{domain}.sol başarıyla gönderildi!" #: src/screens/SearchResult.tsx:59 -msgid "{input}.sol is not a valid domain" -msgstr "{input}.sol geçerli bir domain değil" +#~ msgid "{input}.sol is not a valid domain" +#~ msgstr "{input}.sol geçerli bir domain değil" + +#: src/screens/SearchResult.tsx:64 +msgid "{inputFieldValue}.sol is not a valid domain" +msgstr "" #: src/screens/HomeScreen.tsx:54 msgid "{search}.sol is not a valid domain" @@ -477,12 +481,12 @@ msgstr "Domainler ara" #: src/screens/HomeScreen.tsx:95 #: src/screens/Profile/index.tsx:193 -#: src/screens/SearchResult.tsx:72 +#: src/screens/SearchResult.tsx:77 msgid "Search for a domain" msgstr "Domain için arama yap" #: src/screens/HomeScreen.tsx:107 -#: src/screens/SearchResult.tsx:85 +#: src/screens/SearchResult.tsx:90 msgid "Search your .SOL domain" msgstr ".SOL domain isminizi arayın" diff --git a/src/locales/zh-Hans/messages.po b/src/locales/zh-Hans/messages.po index 8b44e9a..4b524b0 100644 --- a/src/locales/zh-Hans/messages.po +++ b/src/locales/zh-Hans/messages.po @@ -28,8 +28,12 @@ msgid "{domain}.sol successfully transfered!" msgstr "{domain}.sol 汇款成功" #: src/screens/SearchResult.tsx:59 -msgid "{input}.sol is not a valid domain" -msgstr "{input}.sol 不是有效的域名" +#~ msgid "{input}.sol is not a valid domain" +#~ msgstr "{input}.sol 不是有效的域名" + +#: src/screens/SearchResult.tsx:64 +msgid "{inputFieldValue}.sol is not a valid domain" +msgstr "" #: src/screens/HomeScreen.tsx:54 msgid "{search}.sol is not a valid domain" @@ -479,12 +483,12 @@ msgstr "搜索域名" #: src/screens/HomeScreen.tsx:95 #: src/screens/Profile/index.tsx:193 -#: src/screens/SearchResult.tsx:72 +#: src/screens/SearchResult.tsx:77 msgid "Search for a domain" msgstr "搜索域名" #: src/screens/HomeScreen.tsx:107 -#: src/screens/SearchResult.tsx:85 +#: src/screens/SearchResult.tsx:90 msgid "Search your .SOL domain" msgstr "搜索你的 .SOL 域名"