adding mounted flags
This commit is contained in:
@@ -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(() => {
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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 },
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"jsx": "react"
|
||||
},
|
||||
"extends": "@react-native/typescript-config",
|
||||
"include": ["**/*.ts", "**/*.tsx"],
|
||||
"exclude": ["**/node_modules", "**/Pods"]
|
||||
|
||||
Reference in New Issue
Block a user