Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken search field #32

Merged
merged 3 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ""

Expand All @@ -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 ""

Expand Down
12 changes: 8 additions & 4 deletions src/locales/es/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"

Expand Down
12 changes: 8 additions & 4 deletions src/locales/fr/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"

Expand Down
12 changes: 8 additions & 4 deletions src/locales/kr/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 "도메인을 검색하기"

Expand All @@ -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 도메인 검색하기"

Expand Down
12 changes: 8 additions & 4 deletions src/locales/tr/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"

Expand Down
12 changes: 8 additions & 4 deletions src/locales/zh-Hans/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 域名"

Expand Down
39 changes: 23 additions & 16 deletions src/screens/SearchResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,48 +27,53 @@ 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<profileScreenProp>();
const isFocused = useIsFocused();
const topDomainsSales = useTopDomainsSales(loadPopular);
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 (
<Screen>
<ScrollView showsHorizontalScrollIndicator={false}>
<CustomTextInput
autoCapitalize="none"
onChangeText={(newText) => setSearch(newText.toLowerCase())}
value={input}
onChangeText={(newText) => setInput(newText.toLowerCase())}
dr497 marked this conversation as resolved.
Show resolved Hide resolved
value={inputFieldValue}
placeholder={t`Search for a domain`}
type="search"
editable={currentModal !== "Error"}
Expand All @@ -81,7 +86,7 @@ export const SearchResult = ({
<View style={tw`mt-4 w-[100%]`}>
<UiButton
onPress={handle}
disabled={!input}
disabled={!inputFieldValue}
content={t`Search your .SOL domain`}
/>
</View>
Expand Down Expand Up @@ -113,7 +118,9 @@ export const SearchResult = ({
</View>
)}

{!results.loading && results.result && suggestions.loading ? (
{!results.loading &&
results.result?.length &&
suggestions.loading ? (
<>
<DomainSearchResultRow
domain={results.result![0].domain}
Expand Down
Loading