Skip to content

Commit bf5274b

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/main'
2 parents a14562d + e2218ef commit bf5274b

File tree

5 files changed

+37
-11
lines changed

5 files changed

+37
-11
lines changed

nr-app/src/common/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function trustrootsMapFilterForPlusCodePrefixes(
4545

4646
export function filterForMapLayerConfig(layerConfig: MapLayer): Filter {
4747
const filter: Filter = {
48-
authors: [layerConfig.pubkey],
48+
...(layerConfig.pubkey ? { authors: [layerConfig.pubkey] } : {}),
4949
kinds: [layerConfig.kind],
5050
};
5151
return filter;

nr-app/src/components/Map.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
coordinatesToPlusCode,
44
plusCodeToCoordinates,
55
plusCodeToRectangle,
6+
isValidPlusCode,
67
} from "@/utils/map.utils";
78
import {
89
FlatList,
@@ -30,7 +31,7 @@ import { MAP_LAYER_KEY, MAP_LAYERS, MapLayer } from "@common/constants";
3031
import {
3132
getFirstLabelValueFromEvent,
3233
getFirstTagValueFromEvent,
33-
isPlusCode,
34+
// isPlusCode,
3435
} from "@common/utils";
3536
import { createSelector } from "@reduxjs/toolkit";
3637
import { matchFilter, NostrEvent } from "nostr-tools";
@@ -47,9 +48,11 @@ const selectEventsForLayers = createSelector(
4748
(layerKey): [MAP_LAYER_KEY, EventWithMetadata[]] => {
4849
const layerConfig = MAP_LAYERS[layerKey];
4950
const filter = filterForMapLayerConfig(layerConfig);
51+
console.log("RETLIF", filter);
5052
const events = allEvents.filter((event) =>
5153
matchFilter(filter, event.event),
5254
);
55+
console.log("STNEVE", events);
5356
return [layerKey, events];
5457
},
5558
);
@@ -94,11 +97,13 @@ const NoteMarker = ({
9497
"open-location-code",
9598
);
9699

97-
if (typeof plusCode === "undefined" || !isPlusCode(plusCode)) {
98-
console.warn(
100+
if (typeof plusCode === "undefined" || !isValidPlusCode(plusCode)) {
101+
console.log(
99102
"#9k8qKM skipping event with missing / invalid plusCode",
100103
event,
101104
);
105+
console.log(plusCode);
106+
console.log("Event tags:", event.event.tags);
102107
return null;
103108
}
104109

@@ -109,6 +114,7 @@ const NoteMarker = ({
109114
const url = getEventLinkUrl(event.event, layerConfig);
110115

111116
const pinColor = layerConfig?.markerColor || "red";
117+
const rectangleColor = layerConfig?.rectangleColor || "rgba(255,0,0,0.5)";
112118

113119
return (
114120
<View>
@@ -131,7 +137,7 @@ const NoteMarker = ({
131137
</Marker>
132138
<Polygon
133139
coordinates={rectangleCoordinates}
134-
fillColor="rgba(0, 200, 0, 0.5)" // Semi-transparent green
140+
fillColor={rectangleColor}
135141
strokeColor="rgba(0, 0, 0, 0.5)" // Semi-transparent black
136142
strokeWidth={2}
137143
/>
@@ -220,11 +226,11 @@ export default function Map() {
220226
keyExtractor={([key]) => key}
221227
renderItem={({ item: [key, config] }) => (
222228
<View style={styles.toggleContainer}>
223-
<Text>{config.title}</Text>
224229
<Switch
225230
value={enabledLayers[key]}
226231
onValueChange={() => void dispatch(toggleLayer(key))}
227232
/>
233+
<Text>{config.title} </Text>
228234
</View>
229235
)}
230236
/>

nr-app/src/utils/map.utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ type PlusCodeShortLength = 2 | 4 | 6 | 8;
55

66
const plusCodeCharacters = "23456789CFGHJMPQRVWX" as const;
77

8+
export function isValidPlusCode(code: string): boolean {
9+
return OpenLocationCode.isValid(code);
10+
}
11+
812
export function coordinatesToPlusCode({
913
latitude,
1014
longitude,

nr-common/constants.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ export const TIMESAFARI_AUTHOR_PUBLIC_KEY =
2727
export type MapLayer = {
2828
title: string;
2929
rootUrl: string;
30-
kind: 30399 | 30398;
30+
kind: 30399 | 30398 | 30397;
3131
pubkey: string;
3232
markerColor: string;
33+
rectangleColor: string;
3334
};
3435

3536
export const MAP_LAYERS = {
@@ -38,28 +39,38 @@ export const MAP_LAYERS = {
3839
rootUrl: "https://hitchmap.com",
3940
kind: 30399,
4041
pubkey: HITCHMAPS_AUTHOR_PUBLIC_KEY,
41-
markerColor: "gold",
42+
markerColor: "yellow",
43+
rectangleColor: "rgba(255, 255, 0, 0.5)",
4244
} as MapLayer,
4345
hitchwiki: {
4446
title: "Hitchwiki",
4547
rootUrl: "https://hitchwiki.org",
4648
kind: 30399,
4749
pubkey: HITCHWIKI_AUTHOR_PUBLIC_KEY,
48-
markerColor: "yellow",
50+
markerColor: "gold",
51+
rectangleColor: "rgba(255, 215, 0, 0.5)",
4952
} as MapLayer,
5053
timesafari: {
5154
title: "Time Safari",
5255
rootUrl: "https://www.timesafari.app",
5356
kind: 30399,
5457
pubkey: TIMESAFARI_AUTHOR_PUBLIC_KEY,
55-
markerColor: "green",
58+
markerColor: "blue",
59+
rectangleColor: "rgba(0, 0, 255, 0.5)",
5660
} as MapLayer,
5761
triphopping: {
5862
title: "Trip Hopping",
5963
rootUrl: "https://www.triphopping.com",
6064
kind: 30398,
6165
pubkey: DEV_PUBKEY,
62-
markerColor: "blue",
66+
markerColor: "brown",
67+
} as MapLayer,
68+
unverified: {
69+
title: "Unverified",
70+
rootUrl: "https://notes.trustroots.org",
71+
kind: 30397,
72+
markerColor: "red",
73+
rectangleColor: "rgba(255, 0, 0, 0.5)",
6374
} as MapLayer,
6475
} as const;
6576
export type MAP_LAYER_KEY = keyof typeof MAP_LAYERS;

nr-common/utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
} from "./constants.ts";
66
import type { Event } from "./mod.ts";
77

8+
89
function last<T>(items: T[]): T {
910
const lastIndex = Math.max(items.length - 1, 0);
1011
return items[lastIndex];
@@ -32,6 +33,10 @@ export function isHexKey(key: string): boolean {
3233
}
3334

3435
export function isPlusCode(code: string) {
36+
return true;
37+
// todo: use OpenLocationCode.isValid instead
38+
// https://github.com/tspoke/typescript-open-location-code/blob/f44c7dd208fc65a903f4ab28381f0b4b59faac47/src/open-location-code.ts#L137
39+
3540
const re =
3641
/(^|\s)([23456789C][23456789CFGHJMPQRV][023456789CFGHJMPQRVWX]{6}\+[23456789CFGHJMPQRVWX]*)(\s|$)/i;
3742
const simpleTestResult = re.test(code);

0 commit comments

Comments
 (0)