diff --git a/src/components/debug-modals/note-debug-modal.tsx b/src/components/debug-modals/note-debug-modal.tsx index 38c13e24b..f045bcf61 100644 --- a/src/components/debug-modals/note-debug-modal.tsx +++ b/src/components/debug-modals/note-debug-modal.tsx @@ -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) { + 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 ( @@ -24,6 +35,10 @@ export default function NoteDebugModal({ event, ...props }: { event: NostrEvent + {/* TODO: extract this out */} + diff --git a/src/helpers/nostr/events.ts b/src/helpers/nostr/events.ts index d5beda31d..bb178ccee 100644 --- a/src/helpers/nostr/events.ts +++ b/src/helpers/nostr/events.ts @@ -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"); } diff --git a/src/helpers/nostr/stream.ts b/src/helpers/nostr/stream.ts index a0754c451..3e0fe91be 100644 --- a/src/helpers/nostr/stream.ts +++ b/src/helpers/nostr/stream.ts @@ -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 diff --git a/src/views/dvm-feed/components/dvm-card.tsx b/src/views/dvm-feed/components/dvm-card.tsx index dd9a29371..5d6cff161 100644 --- a/src/views/dvm-feed/components/dvm-card.tsx +++ b/src/views/dvm-feed/components/dvm-card.tsx @@ -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(null); + useRegisterIntersectionEntity(ref, getEventUID(appData)); + return ( <> - + } diff --git a/src/views/dvm-feed/index.tsx b/src/views/dvm-feed/index.tsx index 9d88c7cf6..ecb14718c 100644 --- a/src/views/dvm-feed/index.tsx +++ b/src/views/dvm-feed/index.tsx @@ -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 ( DVM Feeds @@ -27,11 +31,13 @@ function DVMFeedHomePage() { https://www.data-vending-machines.org/ - - {DMVs.map((appData) => ( - - ))} - + + + {DMVs.map((appData) => ( + + ))} + + ); }