diff --git a/components/FindResidents/index.js b/components/FindResidents/index.js
index 7719f00f4..4cc9372c1 100644
--- a/components/FindResidents/index.js
+++ b/components/FindResidents/index.js
@@ -32,8 +32,10 @@ const FindResidents = ({
const fetchData = async () => {
await getData('residentData').then((residentData) => {
- setData(residentData || []);
- setResidents(residentData.slice() || [].slice());
+ if (residentData) {
+ setData(residentData || []);
+ setResidents(residentData.slice() || [].slice());
+ }
});
const queryParams = {
diff --git a/components/MapView/index.js b/components/MapView/index.js
index 250005f86..8687e8202 100644
--- a/components/MapView/index.js
+++ b/components/MapView/index.js
@@ -8,36 +8,36 @@ import getLocation from '../../modules/geolocation';
import { theme } from '../../modules/theme';
import { getData } from '../../modules/async-storage';
-import { residentIDQuery } from '../../services/parse/crud';
+// import { residentIDQuery } from '../../services/parse/crud';
-const Maps = ({ organization }) => {
+const Maps = () => {
const [region, setRegion] = useState({
latitude: 18.4861,
longitude: -69.9312,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
});
+
const [markers, setMarkers] = useState([]);
useEffect(() => {
- getData('residentData').then((residentData) => {
- setMarkers(residentData);
- });
-
- let isSubscribed = true;
-
- retrieveMarkers().then((records) => {
- if (isSubscribed) {
- if (records.length === 0) {
- setMarkers(records); // sets records if promise is reached during mounting
- }
- }
- });
- return function cleanup() {
- isSubscribed = false; // cancels promise when component unmounts
- };
+ retriveAsyncMarkers();
}, []);
+ // useEffect(() => {
+ // let isSubscribed = true;
+ // retrieveMarkers().then((records) => {
+ // if (isSubscribed) {
+ // if (records !== markers) {
+ // setMarkers(records); // sets records if promise is reached during mounting
+ // }
+ // }
+ // });
+ // return function cleanup() {
+ // isSubscribed = false; // cancels promise when component unmounts
+ // };
+ // }, []);
+
const handleLocation = async () => {
const currentLocation = await getLocation();
const { latitude, longitude } = currentLocation.coords;
@@ -48,25 +48,33 @@ const Maps = ({ organization }) => {
});
};
- const retrieveMarkers = async () => {
- const queryParams = {
- skip: 0,
- offset: 0,
- limit: 10000,
- parseColumn: 'surveyingOrganization',
- parseParam: organization,
- };
-
- return residentIDQuery(queryParams).then((recs) => JSON.parse(JSON.stringify(recs)));
+ const retriveAsyncMarkers = async () => {
+ getData('residentData').then((residentData) => {
+ if (residentData) {
+ setMarkers(residentData);
+ }
+ });
};
+ // const retrieveMarkers = async () => {
+ // const queryParams = {
+ // skip: 0,
+ // offset: 0,
+ // limit: 10000,
+ // parseColumn: 'surveyingOrganization',
+ // parseParam: organization,
+ // };
+
+ // return residentIDQuery(queryParams).then((recs) => JSON.parse(JSON.stringify(recs)));
+ // };
+
return (
- {markers.length > 1 && markers.map((marker) => (
+ {markers && markers.map((marker) => (
marker.location && (
{
onPress={handleLocation}
color={theme.colors.primary}
style={{ backgroundColor: theme.colors.background, opacity: 0.8 }}
-
- // animated
/>
diff --git a/domains/Auth/SignIn/ForgotPassword/index.js b/domains/Auth/SignIn/ForgotPassword/index.js
index 742fcb1fb..862757fa8 100644
--- a/domains/Auth/SignIn/ForgotPassword/index.js
+++ b/domains/Auth/SignIn/ForgotPassword/index.js
@@ -44,7 +44,7 @@ export default function ForgotPassword({ navigation, setForgotPassword }) {
{(formikProps) => (
- {I18n.t('signIn.forgotPassword.enterEmail')}
+ {I18n.t('signIn.forgotPassword.enterEmail')}
{
- const residentData = await fetchResidentData(org);
- storeData(residentData, 'residentData');
+ if (org) {
+ const residentData = await fetchResidentData(org);
+ storeData(residentData, 'residentData');
+ }
});
} catch (e) {
// We might want to provide this error information to an error reporting service