diff --git a/app/components/admin/homeComponents/apps/chatGPT/components/confirmationPage.js b/app/components/admin/homeComponents/apps/chatGPT/components/confirmationPage.js index e1aa79e9..11bb82f4 100644 --- a/app/components/admin/homeComponents/apps/chatGPT/components/confirmationPage.js +++ b/app/components/admin/homeComponents/apps/chatGPT/components/confirmationPage.js @@ -33,6 +33,7 @@ export default function ConfirmChatGPTPage(props) { const [invoiceInformation, setInvoiceInformation] = useState(null); useEffect(() => { + let mounted = true; async function geneateInvoiceAndFee() { try { let creditPrice = props.price; @@ -45,6 +46,7 @@ export default function ConfirmChatGPTPage(props) { if (!didGetData) throw new Error('Unable to get lnurl data'); input = { type: InputTypes.LNURL_PAY, data: didGetData }; } catch (err) { + if (!mounted) return; setError(t('errormessages.invoiceRetrivalError')); return; } @@ -72,6 +74,7 @@ export default function ConfirmChatGPTPage(props) { }), ); } + if (!mounted) return; setInvoiceInformation({ fee: fee.fee, supportFee: fee.supportFee, @@ -79,8 +82,8 @@ export default function ConfirmChatGPTPage(props) { }); } catch (err) { console.log('Error generating invoice and fee for chatGPT:', err); + if (!mounted) return; setError(err.message); - return; } } requestAnimationFrame(() => { @@ -88,6 +91,9 @@ export default function ConfirmChatGPTPage(props) { geneateInvoiceAndFee(); }); }); + return () => { + mounted = false; + }; }, []); const onSwipeSuccess = useCallback(() => { diff --git a/app/components/admin/homeComponents/apps/giftCards/confimPurchase.js b/app/components/admin/homeComponents/apps/giftCards/confimPurchase.js index 915b38f6..acadbcc3 100644 --- a/app/components/admin/homeComponents/apps/giftCards/confimPurchase.js +++ b/app/components/admin/homeComponents/apps/giftCards/confimPurchase.js @@ -47,6 +47,7 @@ export default function ConfirmGiftCardPurchase(props) { const darkModeType = props?.darkModeTyoe; useEffect(() => { + let mounted = true; async function getGiftCardInfo() { try { const postData = { @@ -98,6 +99,7 @@ export default function ConfirmGiftCardPurchase(props) { const description = decodedInvoice.tags.filter( item => item.tagName === 'description', ); + if (!mounted) return; setRetrivedInformation({ countryInfo: countryInfo, productInfo: @@ -112,10 +114,14 @@ export default function ConfirmGiftCardPurchase(props) { }); } catch (err) { console.log(err); + if (!mounted) return; setError(err.message); } } getGiftCardInfo(); + return () => { + mounted = false; + }; }, []); const fee = diff --git a/app/components/admin/homeComponents/apps/onlineListings/index.js b/app/components/admin/homeComponents/apps/onlineListings/index.js index c6b3eadd..3dd66d41 100644 --- a/app/components/admin/homeComponents/apps/onlineListings/index.js +++ b/app/components/admin/homeComponents/apps/onlineListings/index.js @@ -73,6 +73,7 @@ export default function ViewOnlineListings({ removeUserLocal }) { setUserLocal(removeUserLocal); }, [removeUserLocal]); useEffect(() => { + let mounted = true; const fetchListings = async () => { try { const [shopSavedLocation, res] = await Promise.all([ @@ -89,6 +90,7 @@ export default function ViewOnlineListings({ removeUserLocal }) { fetchListings(); reTryCounter.current += 1; } + if (!mounted) return; setData(json); } catch (e) { console.error('Failed to fetch listings', e); @@ -97,6 +99,9 @@ export default function ViewOnlineListings({ removeUserLocal }) { } }; fetchListings(); + return () => { + mounted = false; + }; }, []); // Preprocess businesses once (lowercased fields, sorted) @@ -450,6 +455,7 @@ const styles = StyleSheet.create({ width: '100%', alignSelf: 'center', marginBottom: 30, + maxHeight: 100, }, flatList: { flex: 1, width: '95%', alignSelf: 'center' }, listContent: { paddingTop: 10, paddingBottom: 20 }, diff --git a/app/components/admin/homeComponents/apps/sms4sats/confirmationSlideUp.js b/app/components/admin/homeComponents/apps/sms4sats/confirmationSlideUp.js index 1ec9edf0..199d6a10 100644 --- a/app/components/admin/homeComponents/apps/sms4sats/confirmationSlideUp.js +++ b/app/components/admin/homeComponents/apps/sms4sats/confirmationSlideUp.js @@ -61,6 +61,7 @@ export default function ConfirmSMSPayment(props) { }, [invoiceInformation]); useEffect(() => { + let mounted = true; async function fetchInvoice() { try { const payload = { @@ -104,6 +105,7 @@ export default function ConfirmSMSPayment(props) { t('errormessages.insufficientBalanceError', { planType: 'SMS' }), ); } + if (!mounted) return; setInvoiceInformation({ fee: fee.fee, supportFee: fee.supportFee, @@ -113,10 +115,14 @@ export default function ConfirmSMSPayment(props) { }); } catch (err) { console.log('Error fetching invoice:', err); + if (!mounted) return; setError(err.message); } } fetchInvoice(); + return () => { + mounted = false; + }; }, []); if (error) { diff --git a/app/components/admin/homeComponents/apps/sms4sats/receiveCodeConfirmation.js b/app/components/admin/homeComponents/apps/sms4sats/receiveCodeConfirmation.js index 85e7e264..a9d9470e 100644 --- a/app/components/admin/homeComponents/apps/sms4sats/receiveCodeConfirmation.js +++ b/app/components/admin/homeComponents/apps/sms4sats/receiveCodeConfirmation.js @@ -49,6 +49,7 @@ export default function ConfirmSMSReceiveCode(props) { }, [invoiceInformation]); useEffect(() => { + let mounted = true; async function fetchInvoice() { try { const payload = { @@ -92,6 +93,7 @@ export default function ConfirmSMSReceiveCode(props) { ); } console.log(data); + if (!mounted) return; setInvoiceInformation({ fee: fee.fee, supportFee: fee.supportFee, @@ -105,6 +107,7 @@ export default function ConfirmSMSReceiveCode(props) { }); } catch (err) { console.log('Error fetching invoice:', err); + if (!mounted) return; setError(err.message); } } @@ -113,6 +116,9 @@ export default function ConfirmSMSReceiveCode(props) { fetchInvoice(); }); }); + return () => { + mounted = false; + }; }, []); if (error) { diff --git a/app/components/admin/homeComponents/contacts/addContactsHalfModal.js b/app/components/admin/homeComponents/contacts/addContactsHalfModal.js index e166ee16..8bd336ec 100644 --- a/app/components/admin/homeComponents/contacts/addContactsHalfModal.js +++ b/app/components/admin/homeComponents/contacts/addContactsHalfModal.js @@ -103,20 +103,17 @@ export default function AddContactsHalfModal({ await Promise.all( results.map(async savedContact => { if (!savedContact) return false; - if ( - savedContact.uniqueName === - globalContactsInformation.myProfile.uniqueName - ) + const uniqueName = savedContact?.uniqueName; + const contactUUID = savedContact?.uuid; + const hasProfileImage = savedContact?.hasProfileImage; + if (uniqueName === globalContactsInformation.myProfile.uniqueName) return false; - if (!savedContact?.uuid) return false; + if (!contactUUID) return false; let responseData; - if ( - savedContact.hasProfileImage || - typeof savedContact.hasProfileImage === 'boolean' - ) { - responseData = await getCachedProfileImage(savedContact.uuid); + if (hasProfileImage || typeof hasProfileImage === 'boolean') { + responseData = await getCachedProfileImage(contactUUID); console.log(responseData, 'response'); } diff --git a/app/components/admin/homeComponents/contacts/expandedContactPage.js b/app/components/admin/homeComponents/contacts/expandedContactPage.js index 0cb9dfc4..3af2a472 100644 --- a/app/components/admin/homeComponents/contacts/expandedContactPage.js +++ b/app/components/admin/homeComponents/contacts/expandedContactPage.js @@ -68,7 +68,7 @@ export default function ExpandedContactsPage(props) { useEffect(() => { //listening for messages when you're on the contact - async function updateSeenTransactions() { + function updateSeenTransactions() { const newMessagesList = []; let consecutiveSeenCount = 0; const REQUIRED_CONSECUTIVE_SEEN = 100; diff --git a/app/screens/inAccount/explorePage.js b/app/screens/inAccount/explorePage.js index 1330c857..9e469bda 100644 --- a/app/screens/inAccount/explorePage.js +++ b/app/screens/inAccount/explorePage.js @@ -157,6 +157,8 @@ export default function ExploreUsers() { }, [timeFrame, t, formattedCurrentTime]); useEffect(() => { + let mounted = true; + async function loadExploreData() { try { const pastExploreData = await getLocalStorageItem( @@ -170,6 +172,7 @@ export default function ExploreUsers() { if (masterInfoObject.exploreData && !shouldLoadExporeDataResp) return; if (!shouldLoadExporeDataResp) { + if (!mounted) return; toggleMasterInfoObject({ exploreData: pastExploreData.data }); throw new Error('Blocking call since data is up to date'); } @@ -182,6 +185,7 @@ export default function ExploreUsers() { ); if (freshExploreData) { + if (!mounted) return; toggleMasterInfoObject({ exploreData: freshExploreData }); await setLocalStorageItem( 'savedExploreData', @@ -198,6 +202,9 @@ export default function ExploreUsers() { } } loadExploreData(); + return () => { + mounted = false; + }; }, []); if (isLoading) { diff --git a/tsconfig.json b/tsconfig.json index c41b7e20..a641e40f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,4 +1,7 @@ { + "compilerOptions": { + "jsx": "react" + }, "extends": "@react-native/typescript-config", "include": ["**/*.ts", "**/*.tsx"], "exclude": ["**/node_modules", "**/Pods"]