diff --git a/src/hooks/static-content/useHandleAppBannerMap.ts b/src/hooks/static-content/useHandleAppBannerMap.ts index ce1545375..217e286c5 100644 --- a/src/hooks/static-content/useHandleAppBannerMap.ts +++ b/src/hooks/static-content/useHandleAppBannerMap.ts @@ -56,29 +56,27 @@ export const useHandleAppBannerMap = () => { const filteredData = useMemo(() => { return appBannerData.filter(({ locations, comparison_operator, ios_version_range, app_version_range }) => { - let isValidLocation = true; - let isValidIosVersion = true; - let isValidAppVersion = true; + const validConditionArr = []; if (locations && locations.length) { const countryId = getCountry(); const locationIds = locations.map(item => item.split('_')[1]); - isValidLocation = locationIds.includes(countryId); + validConditionArr.push(locationIds.includes(countryId)); } if (ios_version_range && Platform.OS === 'ios') { const iosVersion = getIosVersion(); - isValidIosVersion = satisfies(iosVersion, ios_version_range); + validConditionArr.push(satisfies(iosVersion, ios_version_range)); } if (app_version_range) { const appVersion = getVersion(); - isValidAppVersion = satisfies(appVersion, app_version_range); + validConditionArr.push(satisfies(appVersion, app_version_range)); } if (comparison_operator === 'AND') { - return isValidLocation && isValidIosVersion && isValidAppVersion; + return validConditionArr.every(c => c); } else { - return isValidLocation || isValidIosVersion || isValidAppVersion; + return validConditionArr.some(c => c); } }); }, [appBannerData]); diff --git a/src/hooks/static-content/useHandleAppPopupMap.ts b/src/hooks/static-content/useHandleAppPopupMap.ts index 78aa8e7a2..12b74db41 100644 --- a/src/hooks/static-content/useHandleAppPopupMap.ts +++ b/src/hooks/static-content/useHandleAppPopupMap.ts @@ -48,29 +48,27 @@ export const useHandleAppPopupMap = () => { const filteredData = useMemo(() => { return appPopupData.filter(({ locations, comparison_operator, ios_version_range, app_version_range }) => { - let isValidLocation = true; - let isValidIosVersion = true; - let isValidAppVersion = true; + const validConditionArr = []; if (locations && locations.length) { const countryId = getCountry(); const locationIds = locations.map(item => item.split('_')[1]); - isValidLocation = locationIds.includes(countryId); + validConditionArr.push(locationIds.includes(countryId)); } if (ios_version_range && Platform.OS === 'ios') { const iosVersion = getIosVersion(); - isValidIosVersion = satisfies(iosVersion, ios_version_range); + validConditionArr.push(satisfies(iosVersion, ios_version_range)); } if (app_version_range) { const appVersion = getVersion(); - isValidAppVersion = satisfies(appVersion, app_version_range); + validConditionArr.push(satisfies(appVersion, app_version_range)); } if (comparison_operator === 'AND') { - return isValidLocation && isValidIosVersion && isValidAppVersion; + return validConditionArr.every(c => c); } else { - return isValidLocation || isValidIosVersion || isValidAppVersion; + return validConditionArr.some(c => c); } }); }, [appPopupData]);