Skip to content

Commit

Permalink
unique key for map markers, removed fetch button, now triggered by ma…
Browse files Browse the repository at this point in the history
…p move
  • Loading branch information
K committed Oct 18, 2024
1 parent 0488084 commit 34417fa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 26 deletions.
26 changes: 2 additions & 24 deletions nr-app/app/(tabs)/list.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,20 @@
// import Ionicons from "@expo/vector-icons/Ionicons";
import {
Button,
SafeAreaView,
ScrollView,
StyleSheet,
Text,
View,
} from "react-native";
import { SafeAreaView, ScrollView, StyleSheet, Text, View } from "react-native";

import { ThemedText } from "@/components/ThemedText";
import { ThemedView } from "@/components/ThemedView";
import { startSubscription } from "@/redux/actions/subscription.actions";
import { useAppDispatch, useAppSelector } from "@/redux/hooks";
import { useAppSelector } from "@/redux/hooks";
import { eventsSelectors } from "@/redux/slices/events.slice";

export default function TabTwoScreen() {
const events = useAppSelector(eventsSelectors.selectAll);
const dispatch = useAppDispatch();

return (
<SafeAreaView>
<ScrollView>
<ThemedView style={styles.titleContainer}>
<ThemedText type="title">Stream of notes</ThemedText>
</ThemedView>
<View>
<Button
title="LOAD 10 NOTES (this button should disappear and notes on this pane should be the notes you see on the map pane)"
onPress={async () => {
dispatch(
startSubscription({
filter: { kinds: [397], limit: 10 },
relayUrls: ["wss://relay.damus.io"],
}),
);
}}
/>
</View>
<View>
<Text style={styles.note}>
We have a total of {events.length} notes.
Expand Down
14 changes: 12 additions & 2 deletions nr-app/src/components/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { StyleSheet, View, Text } from "react-native";

import MapView, { Marker, Callout } from "react-native-maps";
import { eventsSelectors } from "@/redux/slices/events.slice";
import { useAppSelector } from "@/redux/hooks";
import { useAppDispatch, useAppSelector } from "@/redux/hooks";
import { startSubscription } from "@/redux/actions/subscription.actions";

import React, { useState } from "react";
import { Modal, TextInput, Button } from "react-native";
Expand Down Expand Up @@ -48,6 +49,7 @@ export default function Map() {
setSelectedCoordinate(event.nativeEvent.coordinate);
setModalVisible(true);
};
const dispatch = useAppDispatch();

return (
<View style={styles.mapContainer}>
Expand All @@ -58,6 +60,14 @@ export default function Map() {
onLongPress={handleLongPress}
onRegionChangeComplete={(region, details) => {
console.log("#rIMmxg Map move completed", region, details);

dispatch(
startSubscription({
filter: { kinds: [397], limit: 10 },
relayUrls: ["wss://relay.damus.io"],
}),
);

const topRightCoordinates = {
latitude: region.latitude + region.latitudeDelta,
longitude: region.longitude + region.longitudeDelta,
Expand All @@ -78,7 +88,7 @@ export default function Map() {
<Marker coordinate={{ latitude: 52, longitude: 13 }} title="A marker" />

{events.map((event) => (
<NoteMarker event={event} />
<NoteMarker event={event} key={event.event.sig} />
))}
</MapView>

Expand Down

0 comments on commit 34417fa

Please sign in to comment.