Browse Source

Fix officialPluviometer filter in map feed screen

master
GabrielTrettel 4 years ago
parent
commit
7bccacff44
  1. 12
      src/app/components/MapMarkerList.js
  2. 4
      src/app/hooks/selectFromDB.js
  3. 9
      src/app/screens/MapFeedScreen.js

12
src/app/components/MapMarkerList.js

@ -1,4 +1,3 @@
import { StyleSheet, View } from "react-native";
import React from "react"; import React from "react";
import useMarkers from "../hooks/selectFromDB"; import useMarkers from "../hooks/selectFromDB";
import MapMarker from "../components/MapMarker"; import MapMarker from "../components/MapMarker";
@ -8,11 +7,12 @@ function isRequestedValue(
renderRain, renderRain,
renderFlood, renderFlood,
renderRiver, renderRiver,
renderPluviometer
renderPluviometer,
renderOfficialPluviometer
) { ) {
return ( return (
(item.name == "pluviometer" && renderPluviometer) || (item.name == "pluviometer" && renderPluviometer) ||
(item.name == "officialPluviometer") & renderOfficialPluviometer ||
(item.name == "rain" && renderRain) || (item.name == "rain" && renderRain) ||
(item.name == "river" && renderRiver) || (item.name == "river" && renderRiver) ||
(item.name == "flood" && renderFlood) (item.name == "flood" && renderFlood)
@ -25,9 +25,10 @@ function MapMarkerList({
renderFlood = true, renderFlood = true,
renderRiver = true, renderRiver = true,
renderPluviometer = true, renderPluviometer = true,
renderOfficialPluviometer = true,
}) { }) {
const markers = useMarkers(reload); const markers = useMarkers(reload);
console.log(markers.markers.size);
return ( return (
<> <>
{[...markers.markers] {[...markers.markers]
@ -37,7 +38,8 @@ function MapMarkerList({
renderRain, renderRain,
renderFlood, renderFlood,
renderRiver, renderRiver,
renderPluviometer
renderPluviometer,
renderOfficialPluviometer
) )
) )
.map(({ ID, ...val }) => { .map(({ ID, ...val }) => {

4
src/app/hooks/selectFromDB.js

@ -168,7 +168,7 @@ const initialState = { markers: new Set() };
function reducer(state = initialState, action) { function reducer(state = initialState, action) {
// NOTE: removing old pluviometer value to new data can be displayed // NOTE: removing old pluviometer value to new data can be displayed
state.markers.forEach((m) => { state.markers.forEach((m) => {
if (m.name === "pluviometer") {
if (m.name == "pluviometer" || m.name == "officialPluviometer") {
state.markers.delete(m); state.markers.delete(m);
} }
}); });
@ -210,7 +210,7 @@ function buildRandonData(location, addr) {
return { return {
image: custom_assets.pluviometer, image: custom_assets.pluviometer,
ID: ++ID, ID: ++ID,
name: "pluviometer",
name: "officialPluviometer",
title: "Pluviometro Oficial " + i++, title: "Pluviometro Oficial " + i++,
coordinate: { coordinate: {
latitude: location.latitude + i * 0.0003, latitude: location.latitude + i * 0.0003,

9
src/app/screens/MapFeedScreen.js

@ -47,11 +47,10 @@ function MapFeedScreen(props) {
renderRain={datas.rain} renderRain={datas.rain}
renderFlood={datas.flood} renderFlood={datas.flood}
renderPluviometer={datas.pluviometer} renderPluviometer={datas.pluviometer}
renderRiver={datas.river} />
{datas.floodAreas &&(
<MapPolygons/>
)}
renderRiver={datas.river}
renderOfficialPluviometer={datas.officialPluviometer}
/>
{datas.floodAreas && <MapPolygons />}
</MapView> </MapView>
<FloatButton /> <FloatButton />
</View> </View>

Loading…
Cancel
Save