mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-04-11 21:29:26 +02:00
fix bug with missing identifier
This commit is contained in:
parent
18ec60ea61
commit
34c9eb1428
@ -1,4 +1,5 @@
|
||||
import { Modal, ModalOverlay, ModalContent, ModalBody, ModalCloseButton, Flex } from "@chakra-ui/react";
|
||||
import { useCallback, useState } from "react";
|
||||
import { Modal, ModalOverlay, ModalContent, ModalBody, ModalCloseButton, Flex, Button } from "@chakra-ui/react";
|
||||
import { ModalProps } from "@chakra-ui/react";
|
||||
import { nip19 } from "nostr-tools";
|
||||
|
||||
@ -8,8 +9,18 @@ import RawJson from "./raw-json";
|
||||
import RawValue from "./raw-value";
|
||||
import RawPre from "./raw-pre";
|
||||
import { getSharableEventAddress } from "../../helpers/nip19";
|
||||
import clientRelaysService from "../../services/client-relays";
|
||||
import NostrPublishAction from "../../classes/nostr-publish-action";
|
||||
|
||||
export default function NoteDebugModal({ event, ...props }: { event: NostrEvent } & Omit<ModalProps, "children">) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const broadcast = useCallback(() => {
|
||||
setLoading(true);
|
||||
const relays = clientRelaysService.getWriteUrls();
|
||||
const pub = new NostrPublishAction("Broadcast", relays, event, 5000);
|
||||
pub.onComplete.then(() => setLoading(false));
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Modal size="6xl" {...props}>
|
||||
<ModalOverlay />
|
||||
@ -24,6 +35,10 @@ export default function NoteDebugModal({ event, ...props }: { event: NostrEvent
|
||||
<RawJson heading="JSON" json={event} />
|
||||
<RawJson heading="Thread Tags" json={getReferences(event)} />
|
||||
<RawJson heading="Tags referenced in content" json={getContentTagRefs(event.content, event.tags)} />
|
||||
{/* TODO: extract this out */}
|
||||
<Button onClick={broadcast} ml="auto" colorScheme="primary" isLoading={loading}>
|
||||
Broadcast
|
||||
</Button>
|
||||
</Flex>
|
||||
</ModalBody>
|
||||
</ModalContent>
|
||||
|
@ -244,7 +244,7 @@ export function parseCoordinate(a: string, requireD = false, silent = true): Cus
|
||||
if (silent) return null;
|
||||
else throw new Error("Missing pubkey");
|
||||
}
|
||||
if (requireD && !d) {
|
||||
if (requireD && d === undefined) {
|
||||
if (silent) return null;
|
||||
else throw new Error("Missing identifier");
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ export function parseStreamEvent(stream: NostrEvent): ParsedStream {
|
||||
const goal = stream.tags.find((t) => t[0] === "goal")?.[1];
|
||||
const identifier = stream.tags.find((t) => t[0] === "d")?.[1];
|
||||
|
||||
if (!identifier) throw new Error("missing identifier");
|
||||
if (!identifier) throw new Error("Missing Identifier");
|
||||
|
||||
let relays = stream.tags.find((t) => t[0] === "relays");
|
||||
// remove the first "relays" element
|
||||
|
@ -1,15 +1,16 @@
|
||||
import { Card, CardProps, Heading, IconButton, LinkBox, LinkOverlayProps, Text, useDisclosure } from "@chakra-ui/react";
|
||||
import { Link as RouterLink, To } from "react-router-dom";
|
||||
import { useMemo } from "react";
|
||||
import { useMemo, useRef } from "react";
|
||||
|
||||
import { NostrEvent } from "../../../types/nostr-event";
|
||||
import { CodeIcon } from "../../../components/icons";
|
||||
import NoteDebugModal from "../../../components/debug-modals/note-debug-modal";
|
||||
import HoverLinkOverlay from "../../../components/hover-link-overlay";
|
||||
import { DVMAvatarLink } from "./dvm-avatar";
|
||||
import { getEventAddressPointer } from "../../../helpers/nostr/events";
|
||||
import { getEventAddressPointer, getEventUID } from "../../../helpers/nostr/events";
|
||||
import { DVMName } from "./dvm-name";
|
||||
import { AddressPointer } from "nostr-tools/lib/types/nip19";
|
||||
import { useRegisterIntersectionEntity } from "../../../providers/local/intersection-observer";
|
||||
|
||||
export default function DVMCard({
|
||||
appData,
|
||||
@ -21,9 +22,12 @@ export default function DVMCard({
|
||||
const debugModal = useDisclosure();
|
||||
const pointer: AddressPointer = useMemo(() => getEventAddressPointer(appData), [appData]);
|
||||
|
||||
const ref = useRef<HTMLDivElement | null>(null);
|
||||
useRegisterIntersectionEntity(ref, getEventUID(appData));
|
||||
|
||||
return (
|
||||
<>
|
||||
<Card as={LinkBox} display="block" p="4" {...props}>
|
||||
<Card as={LinkBox} display="block" p="4" ref={ref} {...props}>
|
||||
<IconButton
|
||||
onClick={debugModal.onOpen}
|
||||
icon={<CodeIcon />}
|
||||
|
@ -8,6 +8,8 @@ import { useReadRelayUrls } from "../../hooks/use-client-relays";
|
||||
import useSubject from "../../hooks/use-subject";
|
||||
import RequireCurrentAccount from "../../providers/route/require-current-account";
|
||||
import { getEventCoordinate } from "../../helpers/nostr/events";
|
||||
import { useTimelineCurserIntersectionCallback } from "../../hooks/use-timeline-cursor-intersection-callback";
|
||||
import IntersectionObserverProvider from "../../providers/local/intersection-observer";
|
||||
|
||||
function DVMFeedHomePage() {
|
||||
const readRelays = useReadRelayUrls();
|
||||
@ -18,6 +20,8 @@ function DVMFeedHomePage() {
|
||||
|
||||
const DMVs = useSubject(timeline.timeline).filter((e) => !e.tags.some((t) => t[0] === "web"));
|
||||
|
||||
const callback = useTimelineCurserIntersectionCallback(timeline);
|
||||
|
||||
return (
|
||||
<VerticalPageLayout>
|
||||
<Heading size="md">DVM Feeds</Heading>
|
||||
@ -27,11 +31,13 @@ function DVMFeedHomePage() {
|
||||
https://www.data-vending-machines.org/
|
||||
</Link>
|
||||
</Text>
|
||||
<SimpleGrid columns={{ base: 1, md: 1, lg: 2, xl: 3 }} spacing="2">
|
||||
{DMVs.map((appData) => (
|
||||
<DVMCard key={appData.id} appData={appData} to={`/dvm/${getEventCoordinate(appData)}`} />
|
||||
))}
|
||||
</SimpleGrid>
|
||||
<IntersectionObserverProvider callback={callback}>
|
||||
<SimpleGrid columns={{ base: 1, md: 1, lg: 2, xl: 3 }} spacing="2">
|
||||
{DMVs.map((appData) => (
|
||||
<DVMCard key={appData.id} appData={appData} to={`/dvm/${getEventCoordinate(appData)}`} />
|
||||
))}
|
||||
</SimpleGrid>
|
||||
</IntersectionObserverProvider>
|
||||
</VerticalPageLayout>
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user