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

4
src/app/hooks/selectFromDB.js

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

9
src/app/screens/MapFeedScreen.js

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

Loading…
Cancel
Save