소스 검색

fixed filtering anon landmarks

chase 2 년 전
부모
커밋
2ab0c15acd

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

@@ -44,6 +44,9 @@ const IndoorMap: React.FC<IndoorMapProps> = ({ navigation, landmarks, promptAddL
   const imageDim = 0.05 * Dimensions.get("window").width;
 
   const loadLandmarks = applyFilter(landmarks)?.map((item) => {
+    if (!lmTypesIndoor[item.landmark_type]) {
+      return null
+    }
     if (item.floor == floor && SVGdim[0] != 1 && SVGdim[1] != 1) {
       return (
         <Image
@@ -53,7 +56,7 @@ const IndoorMap: React.FC<IndoorMapProps> = ({ navigation, landmarks, promptAddL
           y={item.latitude * SVGdim[1]}
           width={imageDim}
           height={imageDim}
-          href={lmTypesIndoor[item.landmark_type]['image'] as ImageSourcePropType} />
+          href={lmTypesIndoor[item.landmark_type].image as ImageSourcePropType} />
       )
     }
   }

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

@@ -27,9 +27,6 @@ import { VoicePanel } from "../Panels/VoicePanel";
 import mapStyles from "./Map.styles";
 import { useOutdoorMapState } from "./useMapState";
 
-import MapViewDirections from 'react-native-maps-directions';
-
-
 /**
  * An interface representing the user location retrieved from [expo-location]{@link https://docs.expo.dev/versions/latest/sdk/location/}.
  * @category Map

+ 0 - 1
src/components/Map/Panels/AddLandmarkPanel.tsx

@@ -276,7 +276,6 @@ const AddLandmarkPanel: React.FC<AddLandmarkProps> = ({ newLandmark, setNewLandm
 
                                         {newLandmark?.landmark_type ? <Image style={{ marginLeft: 20 }} source={lmTypes[newLandmark.landmark_type].image} />
                                             : null}
-                                            <Text>{currentRoute=="Indoor" ? "INDOOR" : "OUTDOOR"}</Text>
                                     </View>
                                 </View>
                                 {newLandmark?.landmark_type ?

+ 2 - 2
src/components/Map/Panels/FilterPanel/FilterPanel.tsx

@@ -120,9 +120,9 @@ export const FilterPanel: React.FC<FilterPanelProps> = (props) => {
 
     const OwnedFilter: React.FC = () => {
         return (
-            <View style={{flexDirection: 'row', alignItems: 'center', marginBottom: 10}} >
+            <View style={{flexDirection: 'row', paddingTop: 10, paddingBottom: 15}} >
                 <Text>Only show my landmarks:</Text>
-                <Checkbox value={localOwned} onValueChange={() => toggleLocalOwned(!localOwned)} boxType="square" style={{marginLeft: 20, width: 25, height: 25, marginBottom:10}} />
+                <Checkbox value={localOwned} onValueChange={() => toggleLocalOwned(!localOwned)} boxType="square" style={{marginLeft: 10, width: 20, height: 20}} />
             </View>
         )
     }

+ 7 - 5
src/components/Map/Panels/LandmarkDetailsPanel/DetailsBody.tsx

@@ -14,7 +14,7 @@ import { QueryStatus } from "react-query";
 import { LMComment } from "../../../../data/comments";
 import { Landmark, LMPhoto } from "../../../../data/landmarks";
 import { MainTabsNavigationProp } from "../../../../navigation/MainTabsNavigator";
-import { lmTypes as lmTypess , lmTypesIndoor } from "../../../../utils/GlobalUtils";
+import { lmTypes as allLmTypes , lmTypesIndoor } from "../../../../utils/GlobalUtils";
 import { IconButton, PrimaryButton } from "../../../Buttons";
 import { PhotoPicker } from "../../../PhotoPicker";
 import { Separator } from "../../../Separator";
@@ -70,7 +70,7 @@ export const DetailsBody: React.FC<DetailsBodyProps> = (props) => {
     }, [navigationState])
 
 
-    let lmTypes = lmTypess
+    let lmTypes = allLmTypes
     if(currentRoute=="Indoor") {
         lmTypes = lmTypesIndoor
     }
@@ -97,10 +97,12 @@ export const DetailsBody: React.FC<DetailsBodyProps> = (props) => {
             <>
                 <Picker
                     style={{
-                        inputIOS: {color: 'white', textAlignVertical: 'center'}, 
+                        inputIOS: {flexDirection: 'row', 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'}}}
+                        inputIOSContainer: {},
+                        viewContainer: { padding: 5, elevation: 1, flex: 1, marginTop: 5}, 
+                        placeholder: {color: 'white'}}}
                     placeholder={{}}
                     Icon={() => <FontAwesome name="chevron-down" color='white' size={20} />}
                     value={props.updatedLandmark?.landmark_type}
@@ -132,7 +134,7 @@ export const DetailsBody: React.FC<DetailsBodyProps> = (props) => {
                         <Text style={{color: 'white', fontSize: 13}}>{props.landmark?.description}</Text>
                     </ScrollView>
                 </View>
-                {props.landmark?.landmark_type ? <Image source={lmTypes[props.landmark?.landmark_type].image} /> : null}
+                {props.landmark?.landmark_type ? <Image source={lmTypes[props.landmark?.landmark_type]?.image} /> : null}
             </View>
         )
     }

+ 0 - 6
src/components/Map/Panels/VoicePanel.tsx

@@ -114,12 +114,6 @@ export const VoicePanel: React.FC<VoicePanelProps> = ({
         }
     }
 
-    const renderCount = useRef<number>(0)
-    useEffect(() => {
-        renderCount.current++
-        console.log("render count: ", renderCount.current);
-    })
-
     useEffect(() => {
         if (voiceVisible) console.log('[Map]: Voice panel openeing')
         else console.log('[Map]: Voice panel closing')

+ 2 - 4
src/navigation/MapNavigator.tsx

@@ -35,7 +35,7 @@ export type MapStackParamList = {
 export type MapStackNavigationProp = StackNavigationProp<MapStackParamList>
 
 const MapNavigator: React.FC = ({ }) => {
-    const { userId, anonUserId } = useAuth()
+    const { landmarkOwnedByUser } = useAuth()
     const mapState = useMapState()
     const authNavigation = useNavigation() as MainTabsNavigationProp
     const authRoute = useRoute() as AuthTabsMapRouteProp
@@ -68,7 +68,6 @@ const MapNavigator: React.FC = ({ }) => {
     useEffect(() => {
         const refetchLandmarksOnFilterOptionsChange = async () => {
             applyFilters(landmarksQuery?.data)
-            console.log('[Map]: Filters changed')
         }
         refetchLandmarksOnFilterOptionsChange()
     }, [mapState.lmFilteredTypes, mapState.onlyOwned, mapState.minLmRating])
@@ -84,7 +83,7 @@ const MapNavigator: React.FC = ({ }) => {
             }
 
             if (mapState.onlyOwned) {
-                landmarks = landmarks?.filter(lm => lm.user == userId || lm.anonymous == anonUserId);
+                landmarks = landmarks?.filter(lm => landmarkOwnedByUser(lm));
             }
         }
 
@@ -121,7 +120,6 @@ const MapNavigator: React.FC = ({ }) => {
     return (
         <View style={{ flex: 1 }}>
             <MapStackNavigator.Navigator screenOptions={{ headerShown: false }} initialRouteName="Outdoor">
-
                 <MapStackNavigator.Screen name="Outdoor" >
                     {({ navigation }) =>
                         <OutdoorMap