Преглед изворни кода

fixed issue occuring when there are no nearby landmarjs

chase пре 2 година
родитељ
комит
79611f80d0

+ 0 - 114
src/components/Auth/RegistrationSteps/RegisterCredential.tsx

@@ -1,114 +0,0 @@
-/* Copyright (C) Click & Push Accessibility, Inc - All Rights Reserved
- * Unauthorized copying of this file, via any medium is strictly prohibited
- * Proprietary and confidential
- * Written and maintained by the Click & Push Development team 
- * <dev@clicknpush.ca>, January 2022
- */
-
-import { Formik } from 'formik';
-import React from 'react';
-import { Dimensions, StyleSheet, TextInput, View } from 'react-native';
-import 'react-native-get-random-values';
-import { Text } from 'react-native-paper';
-import { credsSchema, RegisterCredsValues } from '../../../utils/RegistrationUtils';
-import { PrimaryButton } from '../../Buttons';
-import { RegisterStepProps } from '../RegisterMain';
-
-/**
- * This component displays a form for the new user's email and password to-be.
- */
-const RegisterCredentials: React.FC<RegisterStepProps> = ({changeStep, setFormValues, formValues}) => {
-    /**
-   * The initial measurement values are set to the current email and username values of the parent form data object
-   */
-    const initialValues: RegisterCredsValues = {email: formValues.email, username: formValues.username};
-
-    /* 
-    * Updates the form values and progresses to the password step
-    */
-    const next = (newFormValues: RegisterCredsValues) => {
-      setFormValues({...formValues, email: newFormValues.email, username: newFormValues.username});
-      console.log("[Registration]: Registration form values updated")
-      changeStep(2, "Next, we'll have you set a password.");
-    }
-  
-    return (
-        <Formik 
-            initialValues={initialValues}
-            validationSchema={credsSchema}
-            enableReinitialize={true}
-            onSubmit={values => next(values)}>
-            {({ handleChange, handleBlur, handleSubmit, values, errors, touched }) => (
-              <View style={{margin: 20}}>
-                  <TextInput 
-                    style={styles.textInput}
-                    placeholder="Username" 
-                    value={values.username}
-                    onChangeText={handleChange('username')}
-                    onBlur={handleBlur('username')} />
-                  {errors.username && touched.username ? <Text style={styles.errorText}>{errors.username}</Text> : null}
-                  <TextInput 
-                    style={styles.textInput}
-                    placeholder="Email" 
-                    value={values.email}
-                    onChangeText={handleChange('email')} 
-                    onBlur={handleBlur('email')} />
-                  {errors.email && touched.email ? <Text style={styles.errorText}>{errors.email}</Text> : null}
-                  <PrimaryButton style={{marginTop: 30}} onPress={handleSubmit as any} text="Next"/>
-              </View>
-            )}
-        </Formik>
-    ) 
-}
-
-const styles = StyleSheet.create({
-    container: {
-      position: 'absolute',
-      width: Dimensions.get('window').width,
-      height: Dimensions.get('window').height,
-      flex: 1,
-      justifyContent: 'flex-start',
-      resizeMode: 'cover',
-    },
-  
-    textContainer: { 
-      marginHorizontal: 20,
-      marginBottom: 30,
-      borderRadius: 50,
-    },
-  
-    textInput: {
-      marginVertical: 7,
-      paddingLeft: 30,
-      borderRadius: 50,
-      overflow: 'hidden',
-      backgroundColor: 'white',
-      height: 50
-    },
-
-    errorText: {
-      alignSelf: 'flex-end',
-      color: 'red',
-      fontSize: 15,
-      marginBottom: 10,
-    },
-
-    errorInput: {
-      borderWidth: 2,
-      borderColor: 'red'
-    },
-  
-    nextBtn: {
-      marginHorizontal: 20,
-      marginBottom: 60,
-      borderRadius: 50,
-      justifyContent: 'center',
-      backgroundColor: '#df3f3f',
-      margin: 5,
-      height: 50,
-      alignItems: 'center'
-    },
-  })
- 
-export default RegisterCredentials;
- 

+ 0 - 136
src/components/Auth/RegistrationSteps/RegisterImage.tsx

@@ -1,136 +0,0 @@
-/* Copyright (C) Click & Push Accessibility, Inc - All Rights Reserved
- * Unauthorized copying of this file, via any medium is strictly prohibited
- * Proprietary and confidential
- * Written and maintained by the Click & Push Development team 
- * <dev@clicknpush.ca>, January 2022
- */
-
-import axios from 'axios';
-import React, { useState } from 'react';
-import { Image, TouchableOpacity, View } from 'react-native';
-import 'react-native-get-random-values';
-import { ActivityIndicator, Text } from 'react-native-paper';
-import { API_URL, reportAxiosError } from '../../../utils/RequestUtils';
-import { PrimaryButton, SecondaryButton } from '../../Buttons';
-import { PhotoPicker } from '../../PhotoPicker';
-import { Separator } from '../../Separator';
-import { RegisterStepProps } from '../RegisterMain';
-
-/**
- * This component displays an interface to upload a profile picture
- */
-const RegisterImage: React.FC<RegisterStepProps> = ({changeStep, formValues}) => {
-  /**
-   * Stores the base64 of the user's selected profile pic
-   */ 
-  const [photoBase64, setPhotoBase64] = useState<string>();
-  /**
-   * This flag is set to true when the registration submission is being processed. An activity spinner will display while it is true
-   */ 
-  const [loadingSubmission, toggleLoading] = useState<boolean>(false);
-  /**
-   * This flag toggles the menu that is used to choose a photo source (Library or Camera).
-   */ 
-  const [photoSourceMenuOpened, togglePhotoSourceMenu] = useState<boolean>(false)
-
-  /**
-     * Reverse back to measurements step
-     */ 
-  const back = () => {
-    console.log("[Registration]: Registration form values updated")
-    changeStep(3, "Will you be using a Sagitta?")
-  }
-
-  /**
-   * Prepares and sends a registration request to the api
-   */ 
-  const register = async () => {
-    // toggle the loading flag and change status
-    toggleLoading(true);
-    changeStep(4, 'Hang tight for a moment while we create your account.')
-
-    // create FormData and send request
-    const formData = prepareFormData()    
-    await sendRegisterRequest(formData)
-  }
-
-  // Returns a FormData object containing all the form values from each registration step, including the image (in b64) chosen on this step
-  const prepareFormData = (): FormData =>  {
-    console.log("[Registration]: Preparing form data...")
-    let formData = new FormData();
-    let processedFormValues;
-    if (formValues.height && formValues.weight) {
-      processedFormValues = {...formValues, height: parseFloat(formValues.height), weight: parseFloat(formValues.weight)}
-    }
-    else {
-      processedFormValues = {
-        email: formValues.email,
-        username: formValues.username,
-        password: formValues.password,
-      };
-    }
-    formData.append('userInfo', JSON.stringify(processedFormValues));
-    formData.append('avatar', 'data:image/png;base64,' + photoBase64);
-
-    console.log("[Registration]: Form data prepared")
-    return formData
-  }
-
-  const sendRegisterRequest = async (formData: FormData) => {
-    // initialize registration result message
-    let resultMessage = '';
-
-    console.log("[Registration]: Sending registration request...")
-    // send request, notify user of result
-
-    try {
-      const response = await axios({
-        method: 'post',
-        url: API_URL + '/api/register/',
-        timeout: 50000,
-        data: formData,
-      });
-      if (response.status == 200) {
-        resultMessage = 'Success! Congratulations on registering for your new account, you can now login!';  
-      }
-      else {
-        resultMessage = 'Something went wrong when trying to set up your account. Please try again.'; // TODO: add contact details?  
-      }
-      
-    } catch (error) {
-      resultMessage = 'Something went wrong when trying to set up your account. Please try again.'; // TODO: add contact details?
-      reportAxiosError('Something went wrong with user registration', error);
-    }
-    toggleLoading(false);
-    changeStep(5, resultMessage); 
-  }
-
-  return (
-    <View>
-      { !loadingSubmission ?
-      <View>
-        <TouchableOpacity onPress={() => togglePhotoSourceMenu(true)} style={{justifyContent: 'center', }}>
-          { photoBase64 != null ?
-          <Image style={{alignSelf: 'center', borderRadius: 100, width: 200, height: 200, marginBottom: 5, marginTop: 30,}} source={{uri: 'data:image/png;base64,' + photoBase64}} /> :
-          <Image style={{alignSelf: 'center', borderRadius: 100, width: 200, height: 200, marginBottom: 5, marginTop: 30,}} source={require('../../../../assets/default-pfp.png')} /> 
-          }   
-          <Text style={{alignSelf: 'center', marginVertical: 20, color: 'white'}}>Choose photo</Text>
-        </TouchableOpacity>
-        <View style={{margin: 20}}>
-          <Separator color="lightgray" />
-          <PrimaryButton text="Register" onPress={register} style={{marginVertical: 20}} />
-          <SecondaryButton text="Back" onPress={back} style={{marginBottom: 20}} />
-        </View> 
-      </View>
-      : 
-      <View>
-          <ActivityIndicator style={{marginTop: 200}} size="large" animating={true} color="red"/>
-      </View>}
-      <PhotoPicker menuType='alert' multiple={false} photoSourceMenuOpened={photoSourceMenuOpened} cancel={() => togglePhotoSourceMenu(false)} onReceivedPhotoResult={result => setPhotoBase64(result.base64)}/>
-    </View>
-    
-  )
-}
- 
-export default RegisterImage;
- 

+ 0 - 196
src/components/Auth/RegistrationSteps/RegisterMeasurements.tsx

@@ -1,196 +0,0 @@
-/* Copyright (C) Click & Push Accessibility, Inc - All Rights Reserved
- * Unauthorized copying of this file, via any medium is strictly prohibited
- * Proprietary and confidential
- * Written and maintained by the Click & Push Development team 
- * <dev@clicknpush.ca>, January 2022
- */
-
-import { Formik } from 'formik';
-import React, { useState } from 'react';
-import { Dimensions, StyleSheet, TextInput, View } from 'react-native';
-import 'react-native-get-random-values';
-import { RadioButton, Text } from 'react-native-paper';
-import 'react-native-vector-icons';
-import * as Yup from 'yup';
-import { PrimaryButton, SecondaryButton } from '../../Buttons';
-import { RegisterStepProps } from '../RegisterMain';
-
-export interface RegisterMeasurementValues {
-  sagitta: boolean,
-  height: string,
-  weight: string,
-}
-
-/** A yup form validation object for the measurement values */
-const credsSchema = Yup.object({
-  height: Yup.number().required("You must enter a height."),
-  weight: Yup.number().required("You must enter a weight."),
-})
-
-/**
- * This component displays a form for the new user's sagitta usage, height, and weight 
- */
-const RegisterMeasurements: React.FC<RegisterStepProps> = ({changeStep, setFormValues, formValues}) => {
-  /**
- * The initial measurement values are set to the current height and weight values of the parent form data object
- */
-  const initialValues: RegisterMeasurementValues = {sagitta: false, height: formValues.height, weight: formValues.weight};''
-  /**
-   * A flag that maps to whether or not the user is using a sagitta
-   */
-  const [sagitta, setSagitta] = useState<boolean>(false)
-
-  /**
-   * Reverses back to the password step
-   */
-  const back = () => {
-    changeStep(2, "Next, we'll have you set a password.")
-  }
-
-  /**
-   * Advances to the image step
-   */
-  const next = async (newFormValues: RegisterMeasurementValues) => {
-    setFormValues({...formValues, height: newFormValues.height, weight: newFormValues.weight})
-    changeStep(4, "Lastly, pick a photo you'd like everyone to get to know you by.")
-  }
-
-  return (  
-      <View>
-        <View style={styles.sagittaCheck}>
-          <RadioButton uncheckedColor="white" color="white" value="yes" status={ sagitta ? 'checked' : 'unchecked' } onPress={() => setSagitta(true)} />
-          <Text style={styles.radioLabel}>Yes</Text>
-          <RadioButton uncheckedColor="white" color="white" value="no" status={ !sagitta ? 'checked' : 'unchecked' } onPress={() => setSagitta(false)} />
-          <Text style={styles.radioLabel}>No</Text>
-        </View>
-      { sagitta ?
-      <Formik
-        initialValues={initialValues}
-        validationSchema={credsSchema}
-        enableReinitialize={true}
-        onSubmit={values => next(values)}>
-        {({ handleChange, handleBlur, handleSubmit, values, errors }) => (
-          <View style={{margin: 20}}>
-              <TextInput 
-                style={styles.textInput}
-                placeholder="Height" 
-                keyboardType="numeric"
-                value={values.height}
-                onChangeText={handleChange('height')}
-                onBlur={handleBlur('height')} />
-              {errors.height? <Text style={styles.errorText}>{errors.height}</Text> : null}
-              <TextInput 
-                style={styles.textInput}
-                placeholder="Weight" 
-                value={values.weight}
-                onChangeText={handleChange('weight')} 
-                onBlur={handleBlur('weight')} />
-              {errors.weight? <Text style={styles.errorText}>{errors.weight}</Text> : null}
-              <PrimaryButton style={{marginTop: 30}} onPress={handleSubmit as any} text="Next"/>
-              <SecondaryButton onPress={back} text="Back"/>
-          </View>
-        )}
-        </Formik> : 
-        <>
-        <PrimaryButton style={{marginTop: 30}} onPress={() => next({sagitta: false, height: '', weight: ''})} text="Next"/>
-        <SecondaryButton onPress={back} text="Back"/>
-        </> }
-      </View>
-  )
-}
-
-const styles = StyleSheet.create({
-  container: {
-    backgroundColor: 'transparent',
-    
-    position: 'absolute',
-    width: Dimensions.get('window').width,
-    height: Dimensions.get('window').height,
-    flex: 1,
-    flexDirection: 'column',
-    resizeMode: 'cover',
-  },
-
-  brandContainer: {
-    marginTop: 70,  
-    height: 120,
-    marginLeft: 25,
-    flexDirection: 'column',
-    justifyContent: 'space-evenly'
-  },
-
-  title: {
-    
-    color: 'white',
-    fontSize: 20
-  },
-
-  sagittaCheck: {
-    flexDirection: 'row',
-    margin: 20
-  },
-
-  radioLabel: {
-    marginTop: 7, marginRight: 20, color: 'white'
-  },
-
-  subtitle: {
-      
-      color: 'white',
-      fontSize: 15,
-      marginHorizontal: 20,
-      marginTop: 20
-  },
-
-  textContainer: { 
-    marginHorizontal: 20,
-    marginBottom: 30,
-    borderRadius: 50,
-  },
-
-  textInput: {
-    marginVertical: 7,
-    paddingLeft: 30,
-    borderRadius: 50,
-    overflow: 'hidden',
-    backgroundColor: 'white',
-    height: 50
-  },
-
-  errorText: {
-    alignSelf: 'flex-end',
-    color: 'red',
-    fontSize: 15
-  },
-
-  errorInput: {
-    borderWidth: 2,
-    borderColor: 'red'
-  },
-
-  nextBtn: {
-    marginHorizontal: 20,
-
-    borderRadius: 50,
-    justifyContent: 'center',
-    backgroundColor: '#df3f3f',
-    margin: 5,
-    height: 50,
-    alignItems: 'center'
-  },
-
-  backBtn: {
-    marginHorizontal: 20,
-    marginBottom: 10,
-    borderRadius: 50,
-    borderColor: 'white',
-    borderWidth: 2,
-    justifyContent: 'center',
-    backgroundColor: 'transparent',
-    margin: 5,
-    height: 50,
-    alignItems: 'center'
-  },
-})
-
-export default RegisterMeasurements;

+ 0 - 103
src/components/Auth/RegistrationSteps/RegisterPassword.tsx

@@ -1,103 +0,0 @@
-/* Copyright (C) Click & Push Accessibility, Inc - All Rights Reserved
- * Unauthorized copying of this file, via any medium is strictly prohibited
- * Proprietary and confidential
- * Written and maintained by the Click & Push Development team 
- * <dev@clicknpush.ca>, January 2022
- */
-
-import { Formik } from 'formik';
-import React from 'react';
-import { StyleSheet, TextInput, View } from 'react-native';
-import 'react-native-get-random-values';
-import { Text } from 'react-native-paper';
-import { passwordSchema } from '../../../utils/RegistrationUtils';
-import { PrimaryButton, SecondaryButton } from '../../Buttons';
-import { RegisterStepProps } from '../RegisterMain';
-
-export interface PasswordValues {
-  password: string;
-  confirmPassword: string;
-}
-
-const RegisterPassword: React.FC<RegisterStepProps> = ({changeStep, setFormValues, formValues}) => {
-  /**
- * The initial measurement values are set to the current password values of the parent form data object
- */
-  const initialValues: PasswordValues = {password: formValues.password, confirmPassword: formValues.confirmPassword};
-
-  const next = (newFormValues: PasswordValues) => {
-    setFormValues({...formValues, password: newFormValues.password, confirmPassword: newFormValues.confirmPassword});
-    changeStep(3, "Will you be using a Sagitta?");
-  }
-  
-  const back = () => {
-    changeStep(1, "Let's start with some basic account information");
-  }
-
-  return (
-        <Formik
-          initialValues={initialValues}
-          validationSchema={passwordSchema}
-          enableReinitialize={true}
-          onSubmit={values => next(values)}>
-          {({ handleChange, handleBlur, handleSubmit, values, errors, touched }) => (
-              <View style={{margin: 20}}>
-                  <TextInput 
-                    style={PasswordFormStyles.textInput}
-                    placeholder="Password" 
-                    secureTextEntry={true} 
-                    value={values.password}
-                    onChangeText={handleChange('password')}
-                    onBlur={handleBlur('password')} />
-                  {errors.password && touched.password ? <Text style={PasswordFormStyles.errorText}>{errors.password}</Text> : null}
-                  <TextInput 
-                    style={PasswordFormStyles.textInput}
-                    placeholder="Confirm password"
-                    secureTextEntry={true} 
-                    value={values.confirmPassword}
-                    onChangeText={handleChange('confirmPassword')} 
-                    onBlur={handleBlur('confirmPassword')} />
-                  {errors.confirmPassword && touched.confirmPassword ? <Text style={PasswordFormStyles.errorText}>{errors.confirmPassword}</Text> : null}
-                  <PrimaryButton style={{marginTop: 30}} onPress={handleSubmit as any} text="Next"/>
-                  <SecondaryButton onPress={back} text="Back"/>
-              </View>
-            )}
-      </Formik>
-  )
-}
-
-export const PasswordFormStyles = StyleSheet.create({backBtn: {
-    marginHorizontal: 20,
-    marginBottom: 10,
-    borderRadius: 50,
-    borderColor: 'white',
-    borderWidth: 2,
-    justifyContent: 'center',
-    backgroundColor: 'transparent',
-    margin: 5,
-    height: 50,
-    alignItems: 'center'
-  },
-    textInput: {
-      marginVertical: 7,
-      paddingLeft: 30,
-      borderRadius: 50,
-      overflow: 'hidden',
-      backgroundColor: 'white',
-      height: 50
-    },
-
-    errorText: {
-      alignSelf: 'flex-end',
-      color: 'red',
-      fontSize: 15
-    },
-
-    errorInput: {
-      borderWidth: 2,
-      borderColor: 'red'
-    },
-  })
- 
-export default RegisterPassword;
- 

+ 0 - 1
src/components/Map/MainMapComponent/IndoorMap.tsx

@@ -200,7 +200,6 @@ const IndoorMap: React.FC<IndoorMapProps> = ({ navigation, landmarks, promptAddL
               minZoom={1}
               initialOffsetY={5}
               onLongPress={(event) => {
-                console.log("native event is " + event.nativeEvent)
                 // serialize()
                 addLandmark(event)
               }}>

+ 3 - 2
src/components/Map/MainMapComponent/OutdoorMap.tsx

@@ -233,6 +233,7 @@ const OutdoorMap: React.FC<OutdoorMapProps> = (props) => {
      * Method that runs every time user location changes, updates user location state in memory and checks if any landmarks are nearby
      */
     const updateLocation = async (coord: LatLng) => {
+        
         mapState.setUserLocation(coord)
         // get 10m radius around user
         const userAlertRadius = circle([coord.longitude, coord.latitude], 10, {units: 'meters'})
@@ -245,7 +246,7 @@ const OutdoorMap: React.FC<OutdoorMapProps> = (props) => {
 
         // to prevent duplicate notifications make a list of landmarks that weren't previously near the user. 
         // these are the only ones that the user will be notified of
-        const newLandmarksNotPreviouslyNearUser = newLandmarksNearUser.filter(lm => mapState.landmarksNearUser.some(origLm => lm == origLm.id))
+        const newLandmarksNotPreviouslyNearUser = newLandmarksNearUser?.filter(lm => mapState.landmarksNearUser.some(origLm => lm == origLm.id))
 
         // update list
         mapState.setLandmarksNearUser(newLandmarksNearUser)
@@ -350,7 +351,7 @@ const OutdoorMap: React.FC<OutdoorMapProps> = (props) => {
             {/*Map Panels*/}
             {mapState.voicePermission && mapState.locationPermitted ? 
             <VoicePanel 
-                landmarksNearby={mapState.landmarksNearUser.length > 0} 
+                landmarksNearby={mapState.landmarksNearUser?.length > 0} 
                 toggleAlertedLandmarksVisible={mapState.toggleNearbyLmPanel}
                 navigation={props.authNavigation}
                 userCoords={{longitude: mapState.userLocation?.longitude, latitude: mapState.userLocation?.latitude}}

+ 3 - 3
src/components/Map/Panels/AddLandmarkPanel.tsx

@@ -192,12 +192,12 @@ const AddLandmarkPanel: React.FC<AddLandmarkProps> = ({ newLandmark, setNewLandm
                     result: 'base64'
                 })    
 
-                console.log("Image is", uri.substring(0, 100))
+                //console.log("Image is", uri.substring(0, 100))
                 await addLandmarkMutation.mutateAsync({ landmarkValue: newLandmark, photos: photos, indoorLmLocImg: uri }); // pass it in here
 
 
             } catch (error) {
-                console.error("Oops, snapshot failed", error)
+                console.error("[AddLandmarkPanel]: Creating floorplan image containing new landmark failed.", error)
             }
         }
         else {
@@ -351,7 +351,7 @@ const AddLandmarkPanel: React.FC<AddLandmarkProps> = ({ newLandmark, setNewLandm
                 {newLandmark == null || newLandmark.floor == null || newLandmark.landmark_type == null ? <></> :
                     <View style={styles.container}>
                         <Svg>
-                            {console.log("x coord is " + newLandmark.longitude + " and y coord is " + newLandmark.latitude)}
+                            {/* {console.log("x coord is " + newLandmark.longitude + " and y coord is " + newLandmark.latitude)} */}
                             <ImageSVG x={newLandmark.longitude*imgWidth-3} y={newLandmark.latitude*imgHeight-3} width={imageDim} height={imageDim} href={lmTypes[newLandmark.landmark_type]['image'] as ImageSourcePropType} />
                             <IndoorFloor floorNum={newLandmark.floor} />
                         </Svg>

+ 3 - 3
src/components/Map/Panels/LandmarkDetailsPanel/DetailsBody.tsx

@@ -79,18 +79,18 @@ export const DetailsBody: React.FC<DetailsBodyProps> = (props) => {
             <>
                 <Picker
                     style={{
-                        inputIOS: {color: 'white'}, 
-                        inputAndroid: {color: 'white'},
+                        inputIOS: {color: 'white', textAlignVertical: 'center'}, 
+                        inputAndroid: {color: 'white', textAlignVertical: 'center'},
                         iconContainer: {flex: 1, justifyContent: 'center', height: '100%'},
                         viewContainer: {padding: 5, elevation: 1, flex: 1, justifyContent: 'center'}, placeholder: {color: 'white'}}}
                     placeholder={{}}
+                    Icon={() => <FontAwesome name="chevron-down" color='white' size={20} />}
                     value={props.updatedLandmark?.landmark_type}
                     onValueChange={(value) => {
                         props.setUpdatedLandmark({...props.updatedLandmark, landmark_type: value, title: lmTypes[value].label})
                     }}
                     useNativeAndroidPickerStyle={true}
                     items={Object.keys(lmTypes)?.filter(icon => parseInt(icon) != props.landmark?.landmark_type).map(icon => {
-                        console.log(icon)
                         return (
                             {label: lmTypes[parseInt(icon)].label.toUpperCase(), value: icon, key: icon}
                         )})} />

+ 1 - 1
src/components/Map/Panels/NearbyLandmarksPanel.tsx

@@ -52,7 +52,7 @@ const NearbyLandmarksPanel: React.FC<NearbyLandmarksPanelProps> = ({nearbyLandma
             isVisible={alertedLmPanelVisible} >
             <SafeAreaView style={{backgroundColor: colors.red, height: Dimensions.get('window').height * .6}}>
                 <ScrollView>
-                    {alertedLandmarks.map((lm, i) => {
+                    {alertedLandmarks?.map((lm, i) => {
                         return (
                             <TouchableOpacity onPress={() => selectLm(lm)} key={i} style={{flexDirection: 'row', alignItems: 'center', paddingVertical: 10, marginHorizontal: 15, justifyContent: 'space-between', borderBottomWidth: 1, borderColor: 'lightgray'}}>
                                 <Image source={lmTypes[lm.landmark_type].image}/>

+ 13 - 12
src/data/Auth/AuthContext.tsx

@@ -109,7 +109,7 @@ export const AuthContextProvider: React.FC = ({children}) => {
 
             if (accessTokenFromStorage) {
                 try {
-                    await sendApiRequestAsync({
+                    const response = await sendApiRequestAsync({
                         axiosConfig: {
                             method: 'GET',
                             url: '/api/me/',
@@ -118,20 +118,22 @@ export const AuthContextProvider: React.FC = ({children}) => {
                         authorized: false,
                         errorMessage: 'Failed to retrieve user data from server'})
 
-                    setAccessToken(accessTokenFromStorage)
-                    setRefreshToken(await getItemAsync(SECURESTORE_REFRESHTOKEN))
-                    setNotificationToken(await getItemAsync(SECURESTORE_NOTIFTOKEN))
-                    setUserId(await getItemAsync(SECURESTORE_ID))
-                    setAnonUserId('')
-                    return
+                    if (response.status == 200) {
+                        setAccessToken(accessTokenFromStorage)
+                        setRefreshToken(await getItemAsync(SECURESTORE_REFRESHTOKEN))
+                        setNotificationToken(await getItemAsync(SECURESTORE_NOTIFTOKEN))
+                        setUserId(await getItemAsync(SECURESTORE_ID))
+                        setAnonUserId('')
+                        return
+                    }
                 }
                 catch {}
             }
 
-            setAccessTokenAsync("")
-            setRefreshTokenAsync("")
-            setNotificationTokenAsync('')
-            setUserIdAsync('')
+            await setAccessTokenAsync("")
+            await setRefreshTokenAsync("")
+            await setNotificationTokenAsync('')
+            await setUserIdAsync('')
             
             let anonUserId = await getItemAsync(SECURESTORE_ANONID)
             if (anonUserId) {
@@ -206,7 +208,6 @@ export const AuthContextProvider: React.FC = ({children}) => {
             return await axios(axiosConfig)
         } catch (error) {
             reportAxiosError(errorMessage, error)
-            console.log(error.response)
         }
     }
 

+ 0 - 1
src/data/landmarks.ts

@@ -255,7 +255,6 @@ export const useAddLandmarkPhoto = () => {
 
     const addLandmarkPhoto = async (photo: LMPhoto) => {
         if (photo) {
-            console.log(photo.landmark)
             const config: AxiosRequestConfig = {
                 method: 'POST',
                 url: `/api/landmark/photos/`,

+ 4 - 1
src/navigation/RootNavigator.tsx

@@ -3,8 +3,11 @@ import { createNavigationContainerRef } from "@react-navigation/native";
 export const navigationRef = createNavigationContainerRef()
 
 export function navigate(name, params?) {
-  console.log(navigationRef.isReady())
   if (navigationRef.isReady()) {
+    console.log("[Navigation]: Using global navigation to switch to screen: " + name)
     navigationRef.navigate(name as never, params as never);
   }
+  else {
+    console.log("[Navigation]: Global navigation isn't ready.")
+  }
 }

+ 0 - 3
src/utils/GlobalUtils.ts

@@ -84,10 +84,7 @@ export const getMediaPermissions = async () => {
     try {
         const permissionsResult = await checkMultiple(permissions)
         const ungrantedPermissions = permissions.filter(permission => permissionsResult[permission] != RESULTS.GRANTED);
-        console.log(permissionsResult)
-        console.log(ungrantedPermissions)
         if (ungrantedPermissions.length > 0) {
-            console.log('asking for permissions')
             const result = await requestMultiple(ungrantedPermissions)   
             const deniedPermissions = ungrantedPermissions.filter(permission => result[permission] != RESULTS.GRANTED)
             if (deniedPermissions.length > 0) {

+ 3 - 4
src/utils/RequestUtils.ts

@@ -17,8 +17,6 @@ import Config from 'react-native-config'
     if (printResponse) {
         errorString + "\nError response: " + error.response;
     }
-
-    console.error(errorString);
 }
 
 /**
@@ -27,7 +25,8 @@ import Config from 'react-native-config'
 //export const API_URL = 'http://192.168.3.81:8000'
 // export const API_URL = 'https://staging.clicknpush.ca'
 
-// export const API_URL = 'http://192.168.3.162:8000'   // Chase
-export const API_URL = 'http://192.168.3.102:8000'       // Eric
+//export const API_URL = 'http://192.168.3.102:8000'   // Chase
+//export const API_URL = 'http://192.168.0.22:8000'       // Eric
+export const API_URL = 'https://app.clicknpush.ca'
 
 // export const API_URL = Config.API_URL