-
Notifications
You must be signed in to change notification settings - Fork 165
Expand file tree
/
Copy pathRelay.tsx
More file actions
37 lines (33 loc) · 1.17 KB
/
Relay.tsx
File metadata and controls
37 lines (33 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { Event } from 'nostr-tools';
import { useEffect, useState } from 'react';
import Events from '@/nostr/Events';
import { EventMetadata } from '@/nostr/EventsMeta';
import { getOriginalPostEventId } from '@/nostr/utils.ts';
import { hsl, stringToHue } from '@/utils/Helpers';
const NoteRelaysList = ({ event }: { event: Event }) => {
const [eventMeta, setEventMeta] = useState(null as null | EventMetadata);
useEffect(() => {
if (!event?.id) {
return;
}
const id = getOriginalPostEventId(event);
const val = id && Events.eventsMetaDb.get(id);
if (val) {
setEventMeta(val);
}
}, [event]);
const relays = Array.from(eventMeta?.relays || []) as string[];
//console.log(relays);
return (
<div className="flex" style="align-items: center">
{relays.length > 0 ? (
relays.map((r) => (
<div
class="h-3 w-3 rounded-full border border-solid border-gray-6 tooltip"
style={`background: ${hsl(stringToHue(r))}`} data-tip={r} />
))
) : (<span></span>)}
</div>
);
};
export default NoteRelaysList;