mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-09-26 03:28:38 +02:00
@@ -1,6 +1,6 @@
|
||||
import dayjs from "dayjs";
|
||||
import { Kind } from "nostr-tools";
|
||||
import { DraftNostrEvent, NostrEvent, isATag, isDTag, isETag, isPTag } from "../../types/nostr-event";
|
||||
import { DraftNostrEvent, NostrEvent, isATag, isDTag, isETag, isPTag, isRTag } from "../../types/nostr-event";
|
||||
|
||||
export const PEOPLE_LIST_KIND = 30000;
|
||||
export const NOTE_LIST_KIND = 30001;
|
||||
@@ -24,6 +24,9 @@ export function getPubkeysFromList(event: NostrEvent) {
|
||||
export function getEventsFromList(event: NostrEvent) {
|
||||
return event.tags.filter(isETag).map((t) => ({ id: t[1], relay: t[2] }));
|
||||
}
|
||||
export function getReferencesFromList(event: NostrEvent) {
|
||||
return event.tags.filter(isRTag).map((t) => ({ url: t[1], petname: t[2] }));
|
||||
}
|
||||
export function getCoordinatesFromList(event: NostrEvent) {
|
||||
return event.tags.filter(isATag).map((t) => ({ coordinate: t[1], relay: t[2] }));
|
||||
}
|
||||
|
@@ -16,7 +16,13 @@ import {
|
||||
|
||||
import { UserAvatarLink } from "../../../components/user-avatar-link";
|
||||
import { UserLink } from "../../../components/user-link";
|
||||
import { getEventsFromList, getListName, getPubkeysFromList, isSpecialListKind } from "../../../helpers/nostr/lists";
|
||||
import {
|
||||
getEventsFromList,
|
||||
getListName,
|
||||
getPubkeysFromList,
|
||||
getReferencesFromList,
|
||||
isSpecialListKind,
|
||||
} from "../../../helpers/nostr/lists";
|
||||
import { getSharableEventAddress } from "../../../helpers/nip19";
|
||||
import { NostrEvent } from "../../../types/nostr-event";
|
||||
import useReplaceableEvent from "../../../hooks/use-replaceable-event";
|
||||
@@ -32,6 +38,7 @@ import Timestamp from "../../../components/timestamp";
|
||||
function ListCardRender({ event, ...props }: Omit<CardProps, "children"> & { event: NostrEvent }) {
|
||||
const people = getPubkeysFromList(event);
|
||||
const notes = getEventsFromList(event);
|
||||
const references = getReferencesFromList(event);
|
||||
const link = isSpecialListKind(event.kind)
|
||||
? createCoordinate(event.kind, event.pubkey)
|
||||
: getSharableEventAddress(event);
|
||||
@@ -82,6 +89,11 @@ function ListCardRender({ event, ...props }: Omit<CardProps, "children"> & { eve
|
||||
</Flex>
|
||||
</>
|
||||
)}
|
||||
{references.length > 0 && (
|
||||
<>
|
||||
<Text>References ({references.length})</Text>
|
||||
</>
|
||||
)}
|
||||
</CardBody>
|
||||
<CardFooter p="2" display="flex" pt="0">
|
||||
<EventRelays event={event} ml="auto" />
|
||||
|
@@ -7,10 +7,11 @@ import { ArrowLeftSIcon } from "../../components/icons";
|
||||
import { useCurrentAccount } from "../../hooks/use-current-account";
|
||||
import { useDeleteEventContext } from "../../providers/delete-event-provider";
|
||||
import { parseCoordinate } from "../../helpers/nostr/events";
|
||||
import { getEventsFromList, getListName, getPubkeysFromList } from "../../helpers/nostr/lists";
|
||||
import { getEventsFromList, getListName, getPubkeysFromList, getReferencesFromList } from "../../helpers/nostr/lists";
|
||||
import useReplaceableEvent from "../../hooks/use-replaceable-event";
|
||||
import { EventRelays } from "../../components/note/note-relays";
|
||||
import UserCard from "./components/user-card";
|
||||
import OpenGraphCard from "../../components/open-graph-card";
|
||||
import NoteCard from "./components/note-card";
|
||||
import { TrustProvider } from "../../providers/trust";
|
||||
import ListMenu from "./components/list-menu";
|
||||
@@ -49,6 +50,7 @@ export default function ListDetailsView() {
|
||||
const isAuthor = account?.pubkey === event.pubkey;
|
||||
const people = getPubkeysFromList(event);
|
||||
const notes = getEventsFromList(event);
|
||||
const references = getReferencesFromList(event);
|
||||
|
||||
return (
|
||||
<Flex direction="column" px="2" pt="2" pb="8" overflow="hidden" h="full" gap="2">
|
||||
@@ -100,6 +102,23 @@ export default function ListDetailsView() {
|
||||
</TrustProvider>
|
||||
</>
|
||||
)}
|
||||
|
||||
{references.length > 0 && (
|
||||
<>
|
||||
<Heading size="md">References</Heading>
|
||||
<Divider />
|
||||
<TrustProvider trust>
|
||||
<Flex gap="2" direction="column">
|
||||
{references.map(({ url, petname }) => (
|
||||
<>
|
||||
{petname && <Heading size="md">{petname}</Heading>}
|
||||
<OpenGraphCard url={new URL(url)} />
|
||||
</>
|
||||
))}
|
||||
</Flex>
|
||||
</TrustProvider>
|
||||
</>
|
||||
)}
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
|
@@ -302,6 +302,15 @@ export default function UserAboutTab() {
|
||||
>
|
||||
Slidestr Slideshow
|
||||
</Button>
|
||||
<Button
|
||||
as={Link}
|
||||
href={`https://nostree.me/${npub}`}
|
||||
leftIcon={<Image src="https://nostree.me/favicon.svg" w="1.2em" />}
|
||||
rightIcon={<ExternalLinkIcon />}
|
||||
isExternal
|
||||
>
|
||||
Nostree page
|
||||
</Button>
|
||||
</Flex>
|
||||
</Flex>
|
||||
);
|
||||
|
Reference in New Issue
Block a user