diff --git a/src/App.tsx b/src/App.tsx index 4a28d0c..0010451 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -10,6 +10,7 @@ global.Buffer = global.Buffer || require("buffer").Buffer; import { registerRootComponent } from "expo"; import { RecoilRoot, useRecoilState } from "recoil"; import { ActivityIndicator, View, Text } from "react-native"; +import { GestureHandlerRootView } from "react-native-gesture-handler"; import { ReactNode, useEffect } from "react"; import { NavigationContainer } from "@react-navigation/native"; import { createBottomTabNavigator } from "@react-navigation/bottom-tabs"; @@ -195,19 +196,25 @@ function App() { return ( - - - - - - - - - - - - - + {/* + GestureHandlerRootView wrapper because of this + https://github.com/gorhom/react-native-bottom-sheet/issues/1389 + */} + + + + + + + + + + + + + + + ); } diff --git a/src/components/EditPicture.tsx b/src/components/EditPicture.tsx index cc42083..e1dbd6a 100644 --- a/src/components/EditPicture.tsx +++ b/src/components/EditPicture.tsx @@ -16,21 +16,25 @@ import { isTokenized } from "@bonfida/name-tokenizer"; import { t } from "@lingui/macro"; import { PublicKey, TransactionInstruction } from "@solana/web3.js"; import { useStatusModalContext } from "@src/contexts/StatusModalContext"; -import { useSolanaConnection } from "@src/hooks/xnft-hooks"; import { sendTx } from "@src/utils/send-tx"; import { WrapModal } from "./WrapModal"; import { unwrap } from "@src/utils/unwrap"; -import { useWallet } from "@src/hooks/useWallet"; +import { + useWallet, + usePictureRecordValidation, + useSolanaConnection, + useHandleError, +} from "@src/hooks"; import { uploadToIPFS } from "@src/utils/ipfs"; import { UiButton } from "@src/components/UiButton"; import { CustomTextInput } from "@src/components/CustomTextInput"; -import { useHandleError } from "@src/hooks/useHandleError"; export const EditPicture = ({ modal: { closeModal, getParam }, }: { modal: { closeModal: () => void; getParam: (a: string, b?: string) => T }; }) => { + const connection = useSolanaConnection(); const currentPic = getParam("currentPic"); const domain = getParam("domain"); const setAsFav = getParam("domain"); @@ -38,9 +42,9 @@ export const EditPicture = ({ const { setStatus } = useStatusModalContext(); const [loading, setLoading] = useState(false); const [pic, setPic] = useState(""); - const connection = useSolanaConnection(); const { handleError } = useHandleError(); const { publicKey, signTransaction, setVisible, connected } = useWallet(); + const { isValid: isCurrentPicValid } = usePictureRecordValidation(currentPic); const handle = async () => { if (!pic) return; @@ -140,6 +144,7 @@ export const EditPicture = ({ allowsEditing: true, aspect: [1, 1], quality: 0.5, + base64: true, exif: false, }); @@ -149,10 +154,11 @@ export const EditPicture = ({ if (!asset) { throw new Error("Failed to get image asset"); } - const filename = `${domain}-${+Date.now()}.jpg`; + const image = asset.uri.startsWith("data:image") ? asset.uri : asset.base64 || undefined; + if (!image) { throw new Error("Failed to get image"); } @@ -172,14 +178,17 @@ export const EditPicture = ({ setLoading(false); } }; + return ( diff --git a/src/components/ProfileBlock.tsx b/src/components/ProfileBlock.tsx index f979ccc..32b558d 100644 --- a/src/components/ProfileBlock.tsx +++ b/src/components/ProfileBlock.tsx @@ -16,7 +16,9 @@ interface ProfileBlockProps { children?: ReactNode; owner: string; domain: string; - picRecord: ReturnType; + picRecord: string | undefined; + isPicValid: boolean; + onNewPicUploaded: () => void; } export const ProfileBlock = ({ @@ -24,6 +26,8 @@ export const ProfileBlock = ({ domain, children, picRecord, + isPicValid, + onNewPicUploaded, }: ProfileBlockProps) => { const { publicKey } = useWallet(); const { setStatus } = useStatusModalContext(); @@ -52,11 +56,7 @@ export const ProfileBlock = ({ > @@ -64,10 +64,10 @@ export const ProfileBlock = ({ openModal("EditPicture", { - currentPic: picRecord.result, + currentPic: picRecord, domain: domain, setAsFav: !favorite.result?.reverse, - refresh: picRecord.execute, + refresh: onNewPicUploaded, }) } style={tw`h-[24px] w-[24px] rounded-full flex items-center justify-center absolute bottom-0 right-0 bg-brand-accent`} diff --git a/src/components/SearchModal.tsx b/src/components/SearchModal.tsx index f46d8d2..0578115 100644 --- a/src/components/SearchModal.tsx +++ b/src/components/SearchModal.tsx @@ -4,7 +4,6 @@ import { TouchableOpacity, TextInput, Platform, - TouchableWithoutFeedback, FlatList, } from "react-native"; import tw from "../utils/tailwind"; diff --git a/src/contexts/StatusModalContext.tsx b/src/contexts/StatusModalContext.tsx index b3b0977..e326626 100644 --- a/src/contexts/StatusModalContext.tsx +++ b/src/contexts/StatusModalContext.tsx @@ -65,7 +65,7 @@ const StatusModalProvider = ({ children }: { children: React.ReactNode }) => { {children} {currentStatus && ( setContainerWidth(event.nativeEvent.layout.width) } @@ -87,6 +87,7 @@ const StatusModalProvider = ({ children }: { children: React.ReactNode }) => { name="error" size={20} color={tw.color("content-error")} + style={tw`top-0.5`} /> )} {currentStatus.status === "success" && ( @@ -94,14 +95,15 @@ const StatusModalProvider = ({ children }: { children: React.ReactNode }) => { name="checkmark-circle" size={20} color={tw.color("content-success")} + style={tw`top-0.5`} /> )} - + {currentStatus.message} { + const [isValid, setValidStatus] = useState(false); + const checkValidity = async () => { + try { + setValidStatus(false); + if (!pic) return; + await axios.get(pic); + setValidStatus(true); + } catch {} + }; + useEffect(() => { + checkValidity(); + }, [pic]); + + return { + isValid, + }; +}; diff --git a/src/locales/en/messages.po b/src/locales/en/messages.po index 10f48f6..e280dbc 100644 --- a/src/locales/en/messages.po +++ b/src/locales/en/messages.po @@ -123,13 +123,13 @@ msgstr "" #: src/components/CreateSubdomainModal.tsx:92 #: src/components/DeleteModal.tsx:92 -#: src/components/EditPicture.tsx:210 +#: src/components/EditPicture.tsx:219 #: src/components/TransferModal.tsx:109 msgid "Cancel" msgstr "" -#: src/App.tsx:149 -#: src/App.tsx:165 +#: src/App.tsx:150 +#: src/App.tsx:166 msgid "Cart" msgstr "" @@ -137,7 +137,7 @@ msgstr "" msgid "Change language" msgstr "" -#: src/components/EditPicture.tsx:176 +#: src/components/EditPicture.tsx:183 msgid "Change profile picture" msgstr "" @@ -149,7 +149,7 @@ msgstr "" msgid "Clear all" msgstr "" -#: src/screens/Profile/index.tsx:269 +#: src/screens/Profile/index.tsx:286 msgid "Clear search" msgstr "" @@ -257,8 +257,8 @@ msgstr "" msgid "Domain name tokenization (wrapping), involves converting a domain name into an NFT. To reveal the original domain name, the token can be redeemed (unwrapped)." msgstr "" -#: src/App.tsx:139 -#: src/screens/Profile/index.tsx:211 +#: src/App.tsx:140 +#: src/screens/Profile/index.tsx:228 msgid "Domains" msgstr "" @@ -410,7 +410,7 @@ msgstr "" #~ msgid "Invalid IPFS record - Must start with ipfs://" #~ msgstr "" -#: src/components/EditPicture.tsx:57 +#: src/components/EditPicture.tsx:61 #: src/screens/DomainView.tsx:291 msgid "Invalid URL" msgstr "" @@ -428,11 +428,11 @@ msgstr "" msgid "Learn more in our docs" msgstr "" -#: src/screens/Profile/index.tsx:211 +#: src/screens/Profile/index.tsx:228 msgid "My domains" msgstr "" -#: src/screens/Profile/index.tsx:281 +#: src/screens/Profile/index.tsx:298 msgid "My sub domains" msgstr "" @@ -444,7 +444,7 @@ msgstr "" msgid "New {domain}.sol owner" msgstr "" -#: src/components/EditPicture.tsx:199 +#: src/components/EditPicture.tsx:208 msgid "New picture URL" msgstr "" @@ -456,8 +456,8 @@ msgstr "" msgid "No changes to save" msgstr "" -#: src/components/SearchModal.tsx:75 -#: src/screens/Profile/index.tsx:259 +#: src/components/SearchModal.tsx:74 +#: src/screens/Profile/index.tsx:276 msgid "No domain found" msgstr "" @@ -493,7 +493,7 @@ msgstr "" msgid "Payment" msgstr "" -#: src/components/EditPicture.tsx:134 +#: src/components/EditPicture.tsx:138 msgid "Permission to access photo album is required" msgstr "" @@ -501,7 +501,7 @@ msgstr "" msgid "Pic" msgstr "" -#: src/components/EditPicture.tsx:197 +#: src/components/EditPicture.tsx:206 msgid "Picture URL" msgstr "" @@ -517,7 +517,7 @@ msgstr "" msgid "Privacy Policy" msgstr "" -#: src/App.tsx:128 +#: src/App.tsx:129 msgid "Profile" msgstr "" @@ -525,7 +525,7 @@ msgstr "" #~ msgid "Profile completed: {percentage}%" #~ msgstr "" -#: src/screens/Profile/index.tsx:184 +#: src/screens/Profile/index.tsx:201 msgid "Profile completion: {percentage}%" msgstr "" @@ -564,7 +564,7 @@ msgstr "" msgid "Revert" msgstr "" -#: src/components/EditPicture.tsx:217 +#: src/components/EditPicture.tsx:226 #: src/screens/DomainView.tsx:689 msgid "Save" msgstr "" @@ -579,12 +579,12 @@ msgstr "" msgid "Search domain" msgstr "" -#: src/components/SearchModal.tsx:51 +#: src/components/SearchModal.tsx:50 msgid "Search domains" msgstr "" #: src/screens/HomeScreen.tsx:95 -#: src/screens/Profile/index.tsx:218 +#: src/screens/Profile/index.tsx:235 #: src/screens/SearchResult.tsx:77 msgid "Search for a domain" msgstr "" @@ -653,7 +653,7 @@ msgstr "" msgid "Storage:" msgstr "" -#: src/screens/Profile/index.tsx:281 +#: src/screens/Profile/index.tsx:298 msgid "Sub domains" msgstr "" @@ -764,7 +764,7 @@ msgstr "" msgid "Unwrap your domain from NFT" msgstr "" -#: src/components/EditPicture.tsx:191 +#: src/components/EditPicture.tsx:200 msgid "Upload a picture..." msgstr "" diff --git a/src/locales/es/messages.po b/src/locales/es/messages.po index 0b1d25d..9df1c20 100644 --- a/src/locales/es/messages.po +++ b/src/locales/es/messages.po @@ -89,13 +89,13 @@ msgstr "Al hacer clic en \"{actionName}\", se te pedirá una confirmación desde #: src/components/CreateSubdomainModal.tsx:92 #: src/components/DeleteModal.tsx:92 -#: src/components/EditPicture.tsx:210 +#: src/components/EditPicture.tsx:219 #: src/components/TransferModal.tsx:109 msgid "Cancel" msgstr "Cancelar" -#: src/App.tsx:149 -#: src/App.tsx:165 +#: src/App.tsx:150 +#: src/App.tsx:166 msgid "Cart" msgstr "Carrito" @@ -103,7 +103,7 @@ msgstr "Carrito" msgid "Change language" msgstr "Cambiar idioma" -#: src/components/EditPicture.tsx:176 +#: src/components/EditPicture.tsx:183 msgid "Change profile picture" msgstr "Cambiar foto de perfil" @@ -111,7 +111,7 @@ msgstr "Cambiar foto de perfil" msgid "Clear all" msgstr "Limpiar todo" -#: src/screens/Profile/index.tsx:269 +#: src/screens/Profile/index.tsx:286 msgid "Clear search" msgstr "Limpiar búsqueda" @@ -215,8 +215,8 @@ msgstr "¡Descubre el dominio que te representa!" msgid "Domain name tokenization (wrapping), involves converting a domain name into an NFT. To reveal the original domain name, the token can be redeemed (unwrapped)." msgstr "La tokenización de un nombre de dominio (envuelto) implica convertir un nombre de dominio en un NFT. Para revelar el nombre de dominio original, el token puede ser redimido (desenvuelto)." -#: src/App.tsx:139 -#: src/screens/Profile/index.tsx:211 +#: src/App.tsx:140 +#: src/screens/Profile/index.tsx:228 msgid "Domains" msgstr "Dominios" @@ -336,7 +336,7 @@ msgstr "En esto" msgid "Invalid {key} address" msgstr "Dirección {key} inválida" -#: src/components/EditPicture.tsx:57 +#: src/components/EditPicture.tsx:61 #: src/screens/DomainView.tsx:291 msgid "Invalid URL" msgstr "URL inválida" @@ -349,11 +349,11 @@ msgstr "IPFS" msgid "Learn more in our docs" msgstr "Aprende más en nuestra documentación" -#: src/screens/Profile/index.tsx:211 +#: src/screens/Profile/index.tsx:228 msgid "My domains" msgstr "Mis dominios" -#: src/screens/Profile/index.tsx:281 +#: src/screens/Profile/index.tsx:298 msgid "My sub domains" msgstr "" @@ -361,7 +361,7 @@ msgstr "" msgid "New {domain}.sol owner" msgstr "Nuevo propietario de {domain}.sol" -#: src/components/EditPicture.tsx:199 +#: src/components/EditPicture.tsx:208 msgid "New picture URL" msgstr "Nueva URL de imagen" @@ -373,8 +373,8 @@ msgstr "Siguiente" msgid "No changes to save" msgstr "No hay cambios que guardar" -#: src/components/SearchModal.tsx:75 -#: src/screens/Profile/index.tsx:259 +#: src/components/SearchModal.tsx:74 +#: src/screens/Profile/index.tsx:276 msgid "No domain found" msgstr "No se encontró ningún dominio" @@ -402,7 +402,7 @@ msgstr "Pagar con" msgid "Payment" msgstr "Pago" -#: src/components/EditPicture.tsx:134 +#: src/components/EditPicture.tsx:138 msgid "Permission to access photo album is required" msgstr "Se requiere permiso para acceder al álbum de fotos" @@ -410,7 +410,7 @@ msgstr "Se requiere permiso para acceder al álbum de fotos" msgid "Pic" msgstr "Foto" -#: src/components/EditPicture.tsx:197 +#: src/components/EditPicture.tsx:206 msgid "Picture URL" msgstr "URL de la foto" @@ -426,11 +426,11 @@ msgstr "PUNTO" msgid "Privacy Policy" msgstr "" -#: src/App.tsx:128 +#: src/App.tsx:129 msgid "Profile" msgstr "Perfil" -#: src/screens/Profile/index.tsx:184 +#: src/screens/Profile/index.tsx:201 msgid "Profile completion: {percentage}%" msgstr "Finalización del perfil: {percentage}%" @@ -469,7 +469,7 @@ msgstr "Descuento de registro" msgid "Revert" msgstr "Revertir" -#: src/components/EditPicture.tsx:217 +#: src/components/EditPicture.tsx:226 #: src/screens/DomainView.tsx:689 msgid "Save" msgstr "Guardar" @@ -479,12 +479,12 @@ msgstr "Guardar" msgid "Search domain" msgstr "Buscar dominio" -#: src/components/SearchModal.tsx:51 +#: src/components/SearchModal.tsx:50 msgid "Search domains" msgstr "Buscar dominios" #: src/screens/HomeScreen.tsx:95 -#: src/screens/Profile/index.tsx:218 +#: src/screens/Profile/index.tsx:235 #: src/screens/SearchResult.tsx:77 msgid "Search for a domain" msgstr "Buscar un dominio" @@ -523,7 +523,7 @@ msgstr "Tamaño de Almacenamiento" msgid "Storage:" msgstr "Almacenamiento:" -#: src/screens/Profile/index.tsx:281 +#: src/screens/Profile/index.tsx:298 msgid "Sub domains" msgstr "" @@ -612,7 +612,7 @@ msgstr "Desenvolver NFT" msgid "Unwrap your domain from NFT" msgstr "Desenvolver tu dominio del NFT" -#: src/components/EditPicture.tsx:191 +#: src/components/EditPicture.tsx:200 msgid "Upload a picture..." msgstr "Subir una imagen..." diff --git a/src/locales/fr/messages.po b/src/locales/fr/messages.po index 4b560ef..03da1d4 100644 --- a/src/locales/fr/messages.po +++ b/src/locales/fr/messages.po @@ -91,13 +91,13 @@ msgstr "En cliquant sur \"{actionName}\", votre portefeuille vous demandera une #: src/components/CreateSubdomainModal.tsx:92 #: src/components/DeleteModal.tsx:92 -#: src/components/EditPicture.tsx:210 +#: src/components/EditPicture.tsx:219 #: src/components/TransferModal.tsx:109 msgid "Cancel" msgstr "Annuler" -#: src/App.tsx:149 -#: src/App.tsx:165 +#: src/App.tsx:150 +#: src/App.tsx:166 msgid "Cart" msgstr "Panier" @@ -105,7 +105,7 @@ msgstr "Panier" msgid "Change language" msgstr "Changez la langue" -#: src/components/EditPicture.tsx:176 +#: src/components/EditPicture.tsx:183 msgid "Change profile picture" msgstr "Changez votre photo de profil" @@ -113,7 +113,7 @@ msgstr "Changez votre photo de profil" msgid "Clear all" msgstr "Tout effacer" -#: src/screens/Profile/index.tsx:269 +#: src/screens/Profile/index.tsx:286 msgid "Clear search" msgstr "Effacez la recherche" @@ -223,8 +223,8 @@ msgstr "Découvrez le domaine qui vous représente !" msgid "Domain name tokenization (wrapping), involves converting a domain name into an NFT. To reveal the original domain name, the token can be redeemed (unwrapped)." msgstr "La tokenisation (enveloppement) de noms de domaine consiste à convertir un nom de domaine en NFT." -#: src/App.tsx:139 -#: src/screens/Profile/index.tsx:211 +#: src/App.tsx:140 +#: src/screens/Profile/index.tsx:228 msgid "Domains" msgstr "Domaines" @@ -351,7 +351,7 @@ msgstr "Dans cela" msgid "Invalid {key} address" msgstr "Adresse {key} invalide" -#: src/components/EditPicture.tsx:57 +#: src/components/EditPicture.tsx:61 #: src/screens/DomainView.tsx:291 msgid "Invalid URL" msgstr "URL invalide" @@ -364,11 +364,11 @@ msgstr "IPFS" msgid "Learn more in our docs" msgstr "En savoir plus dans nos docs" -#: src/screens/Profile/index.tsx:211 +#: src/screens/Profile/index.tsx:228 msgid "My domains" msgstr "Mes domaines" -#: src/screens/Profile/index.tsx:281 +#: src/screens/Profile/index.tsx:298 msgid "My sub domains" msgstr "" @@ -381,7 +381,7 @@ msgstr "" "\n" "" -#: src/components/EditPicture.tsx:199 +#: src/components/EditPicture.tsx:208 msgid "New picture URL" msgstr "Nouvelle photo de profil" @@ -393,8 +393,8 @@ msgstr "Prochain" msgid "No changes to save" msgstr "Aucuns changements à sauvegarder" -#: src/components/SearchModal.tsx:75 -#: src/screens/Profile/index.tsx:259 +#: src/components/SearchModal.tsx:74 +#: src/screens/Profile/index.tsx:276 msgid "No domain found" msgstr "Aucun domaine trouvé" @@ -422,7 +422,7 @@ msgstr "Payer avec" msgid "Payment" msgstr "Paiement" -#: src/components/EditPicture.tsx:134 +#: src/components/EditPicture.tsx:138 msgid "Permission to access photo album is required" msgstr "" "Une autorisation pour accéder à l'album photo est requise.\n" @@ -436,7 +436,7 @@ msgstr "" msgid "Pic" msgstr "Photo" -#: src/components/EditPicture.tsx:197 +#: src/components/EditPicture.tsx:206 msgid "Picture URL" msgstr "URL de la photo" @@ -452,11 +452,11 @@ msgstr "POINT" msgid "Privacy Policy" msgstr "" -#: src/App.tsx:128 +#: src/App.tsx:129 msgid "Profile" msgstr "Profil" -#: src/screens/Profile/index.tsx:184 +#: src/screens/Profile/index.tsx:201 msgid "Profile completion: {percentage}%" msgstr "Avancement du profil : {pourcentage} %" @@ -495,7 +495,7 @@ msgstr "Remise sur l'enregistrement" msgid "Revert" msgstr "Annuler" -#: src/components/EditPicture.tsx:217 +#: src/components/EditPicture.tsx:226 #: src/screens/DomainView.tsx:689 msgid "Save" msgstr "Sauvegarder" @@ -505,12 +505,12 @@ msgstr "Sauvegarder" msgid "Search domain" msgstr "Recherchez un domaine" -#: src/components/SearchModal.tsx:51 +#: src/components/SearchModal.tsx:50 msgid "Search domains" msgstr "Recherchez des domains" #: src/screens/HomeScreen.tsx:95 -#: src/screens/Profile/index.tsx:218 +#: src/screens/Profile/index.tsx:235 #: src/screens/SearchResult.tsx:77 msgid "Search for a domain" msgstr "Recherchez un domaine" @@ -549,7 +549,7 @@ msgstr "Taille de stockage" msgid "Storage:" msgstr "Stockage:" -#: src/screens/Profile/index.tsx:281 +#: src/screens/Profile/index.tsx:298 msgid "Sub domains" msgstr "" @@ -638,7 +638,7 @@ msgstr "Désenvelopper le NFT" msgid "Unwrap your domain from NFT" msgstr "Désenveloppez votre domaine du NFT" -#: src/components/EditPicture.tsx:191 +#: src/components/EditPicture.tsx:200 msgid "Upload a picture..." msgstr "Téléchargez une photo..." diff --git a/src/locales/kr/messages.po b/src/locales/kr/messages.po index 324273c..5877f98 100644 --- a/src/locales/kr/messages.po +++ b/src/locales/kr/messages.po @@ -125,13 +125,13 @@ msgstr "{actionName}\"을(를) 클릭하면 지갑에서 승인 확인을 받게 #: src/components/CreateSubdomainModal.tsx:92 #: src/components/DeleteModal.tsx:92 -#: src/components/EditPicture.tsx:210 +#: src/components/EditPicture.tsx:219 #: src/components/TransferModal.tsx:109 msgid "Cancel" msgstr "취소" -#: src/App.tsx:149 -#: src/App.tsx:165 +#: src/App.tsx:150 +#: src/App.tsx:166 msgid "Cart" msgstr "장바구니" @@ -139,7 +139,7 @@ msgstr "장바구니" msgid "Change language" msgstr "언어 변경" -#: src/components/EditPicture.tsx:176 +#: src/components/EditPicture.tsx:183 msgid "Change profile picture" msgstr "프로필 사진 변경" @@ -151,7 +151,7 @@ msgstr "프로필 사진 변경" msgid "Clear all" msgstr "모두 지우기" -#: src/screens/Profile/index.tsx:269 +#: src/screens/Profile/index.tsx:286 msgid "Clear search" msgstr "검색 지우기" @@ -259,8 +259,8 @@ msgstr "당신만의 도메인을 탐색하세요!" msgid "Domain name tokenization (wrapping), involves converting a domain name into an NFT. To reveal the original domain name, the token can be redeemed (unwrapped)." msgstr "도메인 이름 토큰화(래핑)는 도메인 이름을 NFT로 변환하는 것을 뜻 합니다. 원래 도메인 이름을 드러내려면 토큰을 인출(언래핑)할 수 있습니다." -#: src/App.tsx:139 -#: src/screens/Profile/index.tsx:211 +#: src/App.tsx:140 +#: src/screens/Profile/index.tsx:228 msgid "Domains" msgstr "도메인" @@ -414,7 +414,7 @@ msgstr "유효하지 않은 {key} 주소" #~ msgid "Invalid IPFS record - Must start with ipfs://" #~ msgstr "유효하지 않은 IPFS 기록 - 반드시 ipfs://로 시작해야 합니다" -#: src/components/EditPicture.tsx:57 +#: src/components/EditPicture.tsx:61 #: src/screens/DomainView.tsx:291 msgid "Invalid URL" msgstr "유효하지 않은 URL입니다" @@ -432,11 +432,11 @@ msgstr "IPFS" msgid "Learn more in our docs" msgstr "문서로 더 알아보세요" -#: src/screens/Profile/index.tsx:211 +#: src/screens/Profile/index.tsx:228 msgid "My domains" msgstr "나의 도메인" -#: src/screens/Profile/index.tsx:281 +#: src/screens/Profile/index.tsx:298 msgid "My sub domains" msgstr "" @@ -448,7 +448,7 @@ msgstr "" msgid "New {domain}.sol owner" msgstr "새로운 {domain}.sol 소유자" -#: src/components/EditPicture.tsx:199 +#: src/components/EditPicture.tsx:208 msgid "New picture URL" msgstr "사진 업로드 URL" @@ -460,8 +460,8 @@ msgstr "다음" msgid "No changes to save" msgstr "저장할 변경 사항이 없습니다" -#: src/components/SearchModal.tsx:75 -#: src/screens/Profile/index.tsx:259 +#: src/components/SearchModal.tsx:74 +#: src/screens/Profile/index.tsx:276 msgid "No domain found" msgstr "도메인을 찾을 수 없습니다" @@ -501,7 +501,7 @@ msgstr "결제 방법" msgid "Payment" msgstr "결제" -#: src/components/EditPicture.tsx:134 +#: src/components/EditPicture.tsx:138 msgid "Permission to access photo album is required" msgstr "사진 앨범에 접근하기 위한 권한이 필요합니다" @@ -509,7 +509,7 @@ msgstr "사진 앨범에 접근하기 위한 권한이 필요합니다" msgid "Pic" msgstr "사진" -#: src/components/EditPicture.tsx:197 +#: src/components/EditPicture.tsx:206 msgid "Picture URL" msgstr "사진 URL" @@ -525,7 +525,7 @@ msgstr "포인트" msgid "Privacy Policy" msgstr "" -#: src/App.tsx:128 +#: src/App.tsx:129 msgid "Profile" msgstr "프로필" @@ -533,7 +533,7 @@ msgstr "프로필" #~ msgid "Profile completed: {percentage}%" #~ msgstr "프로필 완료율: {percentage}%" -#: src/screens/Profile/index.tsx:184 +#: src/screens/Profile/index.tsx:201 msgid "Profile completion: {percentage}%" msgstr "프로필 완성도: {percentage}%" @@ -572,7 +572,7 @@ msgstr "등록 할인" msgid "Revert" msgstr "취소" -#: src/components/EditPicture.tsx:217 +#: src/components/EditPicture.tsx:226 #: src/screens/DomainView.tsx:689 msgid "Save" msgstr "저장" @@ -587,12 +587,12 @@ msgstr "저장" msgid "Search domain" msgstr "도메인 검색" -#: src/components/SearchModal.tsx:51 +#: src/components/SearchModal.tsx:50 msgid "Search domains" msgstr "도메인 검색" #: src/screens/HomeScreen.tsx:95 -#: src/screens/Profile/index.tsx:218 +#: src/screens/Profile/index.tsx:235 #: src/screens/SearchResult.tsx:77 msgid "Search for a domain" msgstr "도메인을 검색하기" @@ -661,7 +661,7 @@ msgstr "저장 용량" msgid "Storage:" msgstr "저장 용량:" -#: src/screens/Profile/index.tsx:281 +#: src/screens/Profile/index.tsx:298 msgid "Sub domains" msgstr "" @@ -767,7 +767,7 @@ msgstr "NFT 언랩하기" msgid "Unwrap your domain from NFT" msgstr "NFT에서 도메인을 언랩하기" -#: src/components/EditPicture.tsx:191 +#: src/components/EditPicture.tsx:200 msgid "Upload a picture..." msgstr "사진 업로드..." diff --git a/src/locales/tr/messages.po b/src/locales/tr/messages.po index 5bf0aae..af402b0 100644 --- a/src/locales/tr/messages.po +++ b/src/locales/tr/messages.po @@ -89,13 +89,13 @@ msgstr "\"{actionName}\"ya tıklayınca cüzdan onayı vermeniz istenecektir. " #: src/components/CreateSubdomainModal.tsx:92 #: src/components/DeleteModal.tsx:92 -#: src/components/EditPicture.tsx:210 +#: src/components/EditPicture.tsx:219 #: src/components/TransferModal.tsx:109 msgid "Cancel" msgstr "İptal" -#: src/App.tsx:149 -#: src/App.tsx:165 +#: src/App.tsx:150 +#: src/App.tsx:166 msgid "Cart" msgstr "Araç" @@ -103,7 +103,7 @@ msgstr "Araç" msgid "Change language" msgstr "Dili değiştir" -#: src/components/EditPicture.tsx:176 +#: src/components/EditPicture.tsx:183 msgid "Change profile picture" msgstr "Profil resmini değiştir" @@ -111,7 +111,7 @@ msgstr "Profil resmini değiştir" msgid "Clear all" msgstr "Tümünü temizle" -#: src/screens/Profile/index.tsx:269 +#: src/screens/Profile/index.tsx:286 msgid "Clear search" msgstr "Aramaları temizle" @@ -215,8 +215,8 @@ msgstr "Seni yansıtan domaini keşfet!" msgid "Domain name tokenization (wrapping), involves converting a domain name into an NFT. To reveal the original domain name, the token can be redeemed (unwrapped)." msgstr "Domain ismini tokenize edilmesi (wrapping), domain isminin NFT'ye dönüşümüdür. Asıl domain isminin tekrardan elde edilmesi için tokenin geri katlanması (unwrapping) gereklidir. " -#: src/App.tsx:139 -#: src/screens/Profile/index.tsx:211 +#: src/App.tsx:140 +#: src/screens/Profile/index.tsx:228 msgid "Domains" msgstr "Domainler" @@ -336,7 +336,7 @@ msgstr "Buna doğru" msgid "Invalid {key} address" msgstr "Geçersiz {key} adresi" -#: src/components/EditPicture.tsx:57 +#: src/components/EditPicture.tsx:61 #: src/screens/DomainView.tsx:291 msgid "Invalid URL" msgstr "Geçersiz URL " @@ -349,11 +349,11 @@ msgstr "IPFS" msgid "Learn more in our docs" msgstr "Dokümanlarımızı okuyarak daha fazla bilgi edinin" -#: src/screens/Profile/index.tsx:211 +#: src/screens/Profile/index.tsx:228 msgid "My domains" msgstr "Domainlerim" -#: src/screens/Profile/index.tsx:281 +#: src/screens/Profile/index.tsx:298 msgid "My sub domains" msgstr "" @@ -361,7 +361,7 @@ msgstr "" msgid "New {domain}.sol owner" msgstr "{domain}.sol'un yeni sahibi" -#: src/components/EditPicture.tsx:199 +#: src/components/EditPicture.tsx:208 msgid "New picture URL" msgstr "Yeni resim URL'si" @@ -373,8 +373,8 @@ msgstr "Sonraki" msgid "No changes to save" msgstr "Kaydedilecek değişiklik yok" -#: src/components/SearchModal.tsx:75 -#: src/screens/Profile/index.tsx:259 +#: src/components/SearchModal.tsx:74 +#: src/screens/Profile/index.tsx:276 msgid "No domain found" msgstr "Domain bulunamadı" @@ -402,7 +402,7 @@ msgstr "ile öde" msgid "Payment" msgstr "Ödeme" -#: src/components/EditPicture.tsx:134 +#: src/components/EditPicture.tsx:138 msgid "Permission to access photo album is required" msgstr "Fotoğraf albümüne erişim izni gereklidir" @@ -410,7 +410,7 @@ msgstr "Fotoğraf albümüne erişim izni gereklidir" msgid "Pic" msgstr "Resim" -#: src/components/EditPicture.tsx:197 +#: src/components/EditPicture.tsx:206 msgid "Picture URL" msgstr "Resim URL'si" @@ -426,11 +426,11 @@ msgstr "PUAN" msgid "Privacy Policy" msgstr "" -#: src/App.tsx:128 +#: src/App.tsx:129 msgid "Profile" msgstr "Profil" -#: src/screens/Profile/index.tsx:184 +#: src/screens/Profile/index.tsx:201 msgid "Profile completion: {percentage}%" msgstr "Profil tamamlama: {percentage}%" @@ -469,7 +469,7 @@ msgstr "Kaydetme indirimi" msgid "Revert" msgstr "Eski haline getir" -#: src/components/EditPicture.tsx:217 +#: src/components/EditPicture.tsx:226 #: src/screens/DomainView.tsx:689 msgid "Save" msgstr "Kaydet" @@ -479,12 +479,12 @@ msgstr "Kaydet" msgid "Search domain" msgstr "Domain ara" -#: src/components/SearchModal.tsx:51 +#: src/components/SearchModal.tsx:50 msgid "Search domains" msgstr "Domainler ara" #: src/screens/HomeScreen.tsx:95 -#: src/screens/Profile/index.tsx:218 +#: src/screens/Profile/index.tsx:235 #: src/screens/SearchResult.tsx:77 msgid "Search for a domain" msgstr "Domain için arama yap" @@ -523,7 +523,7 @@ msgstr "Depo Hacmi" msgid "Storage:" msgstr "Depo" -#: src/screens/Profile/index.tsx:281 +#: src/screens/Profile/index.tsx:298 msgid "Sub domains" msgstr "" @@ -612,7 +612,7 @@ msgstr "NFT'yi geri katla (unwrapping)" msgid "Unwrap your domain from NFT" msgstr "Domaini, NFT'den geri katla (unwrapping)" -#: src/components/EditPicture.tsx:191 +#: src/components/EditPicture.tsx:200 msgid "Upload a picture..." msgstr "Bir resim yükle..." diff --git a/src/locales/zh-Hans/messages.po b/src/locales/zh-Hans/messages.po index 2cd6514..f2bfc2c 100644 --- a/src/locales/zh-Hans/messages.po +++ b/src/locales/zh-Hans/messages.po @@ -89,13 +89,13 @@ msgstr "点击\"{actionName}\",在您的钱包中完成确认" #: src/components/CreateSubdomainModal.tsx:92 #: src/components/DeleteModal.tsx:92 -#: src/components/EditPicture.tsx:210 +#: src/components/EditPicture.tsx:219 #: src/components/TransferModal.tsx:109 msgid "Cancel" msgstr "取消" -#: src/App.tsx:149 -#: src/App.tsx:165 +#: src/App.tsx:150 +#: src/App.tsx:166 msgid "Cart" msgstr "购物车" @@ -103,7 +103,7 @@ msgstr "购物车" msgid "Change language" msgstr "更换语言" -#: src/components/EditPicture.tsx:176 +#: src/components/EditPicture.tsx:183 msgid "Change profile picture" msgstr "更换个人头像" @@ -111,7 +111,7 @@ msgstr "更换个人头像" msgid "Clear all" msgstr "清除所有" -#: src/screens/Profile/index.tsx:269 +#: src/screens/Profile/index.tsx:286 msgid "Clear search" msgstr "清除搜索记录" @@ -215,8 +215,8 @@ msgstr "发现能代表你的域名!" msgid "Domain name tokenization (wrapping), involves converting a domain name into an NFT. To reveal the original domain name, the token can be redeemed (unwrapped)." msgstr "域名通证化(封装)是指将域名转换为 NFT,如果您需要将其恢复为原始域名,可通过转换(解开封装)该通证完成操作。" -#: src/App.tsx:139 -#: src/screens/Profile/index.tsx:211 +#: src/App.tsx:140 +#: src/screens/Profile/index.tsx:228 msgid "Domains" msgstr "域名" @@ -338,7 +338,7 @@ msgstr "进入" msgid "Invalid {key} address" msgstr "无效的 {key} 钱包地址" -#: src/components/EditPicture.tsx:57 +#: src/components/EditPicture.tsx:61 #: src/screens/DomainView.tsx:291 msgid "Invalid URL" msgstr "网址无效" @@ -351,11 +351,11 @@ msgstr "IPFS" msgid "Learn more in our docs" msgstr "在docs中学习更多内容" -#: src/screens/Profile/index.tsx:211 +#: src/screens/Profile/index.tsx:228 msgid "My domains" msgstr "我的域名" -#: src/screens/Profile/index.tsx:281 +#: src/screens/Profile/index.tsx:298 msgid "My sub domains" msgstr "" @@ -363,7 +363,7 @@ msgstr "" msgid "New {domain}.sol owner" msgstr "新的 {domain}.sol 所有者" -#: src/components/EditPicture.tsx:199 +#: src/components/EditPicture.tsx:208 msgid "New picture URL" msgstr "新的图片网址" @@ -375,8 +375,8 @@ msgstr "下一步" msgid "No changes to save" msgstr "无需保存更改" -#: src/components/SearchModal.tsx:75 -#: src/screens/Profile/index.tsx:259 +#: src/components/SearchModal.tsx:74 +#: src/screens/Profile/index.tsx:276 msgid "No domain found" msgstr "未找到域名" @@ -404,7 +404,7 @@ msgstr "支付方式" msgid "Payment" msgstr "支付方式" -#: src/components/EditPicture.tsx:134 +#: src/components/EditPicture.tsx:138 msgid "Permission to access photo album is required" msgstr "请求获取相册权限" @@ -412,7 +412,7 @@ msgstr "请求获取相册权限" msgid "Pic" msgstr "图片" -#: src/components/EditPicture.tsx:197 +#: src/components/EditPicture.tsx:206 msgid "Picture URL" msgstr "图片网址" @@ -428,11 +428,11 @@ msgstr "积分" msgid "Privacy Policy" msgstr "" -#: src/App.tsx:128 +#: src/App.tsx:129 msgid "Profile" msgstr "个人账户" -#: src/screens/Profile/index.tsx:184 +#: src/screens/Profile/index.tsx:201 msgid "Profile completion: {percentage}%" msgstr "个人资料完成度: {percentage}%" @@ -471,7 +471,7 @@ msgstr "注册折扣" msgid "Revert" msgstr "返回" -#: src/components/EditPicture.tsx:217 +#: src/components/EditPicture.tsx:226 #: src/screens/DomainView.tsx:689 msgid "Save" msgstr "保存" @@ -481,12 +481,12 @@ msgstr "保存" msgid "Search domain" msgstr "搜索域名" -#: src/components/SearchModal.tsx:51 +#: src/components/SearchModal.tsx:50 msgid "Search domains" msgstr "搜索域名" #: src/screens/HomeScreen.tsx:95 -#: src/screens/Profile/index.tsx:218 +#: src/screens/Profile/index.tsx:235 #: src/screens/SearchResult.tsx:77 msgid "Search for a domain" msgstr "搜索域名" @@ -525,7 +525,7 @@ msgstr "存储容量" msgid "Storage:" msgstr "存储容量:" -#: src/screens/Profile/index.tsx:281 +#: src/screens/Profile/index.tsx:298 msgid "Sub domains" msgstr "" @@ -614,7 +614,7 @@ msgstr "将NFT解除封装" msgid "Unwrap your domain from NFT" msgstr "将NFT解除封装为你的域名" -#: src/components/EditPicture.tsx:191 +#: src/components/EditPicture.tsx:200 msgid "Upload a picture..." msgstr "上传一张图片..." diff --git a/src/screens/Profile/index.tsx b/src/screens/Profile/index.tsx index cdf8344..8cf76d9 100644 --- a/src/screens/Profile/index.tsx +++ b/src/screens/Profile/index.tsx @@ -8,21 +8,22 @@ import { import { useEffect, useState, useMemo } from "react"; import { useModal } from "react-native-modalfy"; import { useIsFocused } from "@react-navigation/native"; -import { useProfilePic } from "@bonfida/sns-react"; +import { useRecordsV2 } from "@bonfida/sns-react"; import { Trans, t } from "@lingui/macro"; import { Octicons, MaterialCommunityIcons } from "@expo/vector-icons"; import tw from "@src/utils/tailwind"; -import { useDomains } from "@src/hooks/useDomains"; -import { useFavoriteDomain } from "@src/hooks/useFavoriteDomain"; -import { useSolanaConnection } from "@src/hooks/xnft-hooks"; -import { useUserProgress } from "@src/hooks/useUserProgress"; -import { useWallet } from "@src/hooks/useWallet"; import { + usePictureRecordValidation, + useDomains, + useFavoriteDomain, + useSolanaConnection, + useUserProgress, + useWallet, useSubdomainsFromUser, SubdomainResult, -} from "@src/hooks/useSubdomains"; +} from "@src/hooks"; import { Screen } from "@src/components/Screen"; import { DomainRow } from "@src/components/DomainRow"; @@ -31,7 +32,7 @@ import { ProfileBlock } from "@src/components/ProfileBlock"; import { LoadingState } from "./LoadingState"; import { EmptyState } from "./EmptyState"; -import { getDomainKeySync } from "@bonfida/spl-name-service"; +import { Record, getDomainKeySync } from "@bonfida/spl-name-service"; export const ProfileScreen = ({ owner }: { owner?: string }) => { const connection = useSolanaConnection(); @@ -47,7 +48,22 @@ export const ProfileScreen = ({ owner }: { owner?: string }) => { const [searchQuery, setSearchQuery] = useState(""); const isFocused = useIsFocused(); const favorite = useFavoriteDomain(owner); - const picRecord = useProfilePic(connection!, favorite.result?.reverse || ""); + const { + result: picRecordsList = [], + execute: refreshPic, + loading: picLoading, + } = useRecordsV2(connection!, favorite.result?.reverse!, [Record.Pic], true); + + const picRecord = useMemo(() => { + const picRecord = picRecordsList.find( + (r) => r?.record === Record.Pic, + )?.deserializedContent; + + return picRecord; + }, [picRecordsList]); + + const { isValid: isCurrentPicValid } = usePictureRecordValidation(picRecord); + const progress = useUserProgress(); const isOwner = owner === publicKey?.toBase58(); @@ -63,16 +79,13 @@ export const ProfileScreen = ({ owner }: { owner?: string }) => { await Promise.allSettled([ favorite.execute(), progress.execute(), - picRecord.execute(), + refreshPic(), subdomains.execute(), ]); }; const loading = - domains.loading || - picRecord.loading || - progress.loading || - subdomains.loading; + domains.loading || picLoading || progress.loading || subdomains.loading; useEffect(() => { refresh().then(); @@ -176,6 +189,10 @@ export const ProfileScreen = ({ owner }: { owner?: string }) => { owner={owner!} domain={favorite.result?.reverse || domains?.result?.[0]?.domain!} picRecord={picRecord} + isPicValid={isCurrentPicValid} + onNewPicUploaded={() => { + refreshPic(); + }} > {showProgress && isOwner && (