diff --git a/src/components/timeline-page/timeline-health/index.tsx b/src/components/timeline-page/timeline-health/index.tsx index 01d3be9f6..0bfbe8205 100644 --- a/src/components/timeline-page/timeline-health/index.tsx +++ b/src/components/timeline-page/timeline-health/index.tsx @@ -1,4 +1,4 @@ -import { useMemo, useState } from "react"; +import { useState } from "react"; import { Box, Spinner, @@ -14,6 +14,7 @@ import { Tr, useColorMode, } from "@chakra-ui/react"; +import { getSeenRelays } from "applesauce-core/helpers"; import TimelineLoader from "../../../classes/timeline-loader"; import { NostrEvent } from "../../../types/nostr-event"; @@ -23,14 +24,12 @@ import { BroadcastEventIcon } from "../../icons"; import Timestamp from "../../timestamp"; import { usePublishEvent } from "../../../providers/global/publish-provider"; import useEventIntersectionRef from "../../../hooks/use-event-intersection-ref"; -import { getSeenRelays } from "applesauce-core/helpers"; function EventRow({ event, relays, ...props }: { event: NostrEvent; relays: string[] } & Omit) { - // const sub = useMemo(() => getEventRelays(event.id), [event.id]); const publish = usePublishEvent(); const ref = useEventIntersectionRef(event); @@ -42,7 +41,7 @@ function EventRow({ const [broadcasting, setBroadcasting] = useState(false); const broadcast = async () => { setBroadcasting(true); - await publish("Broadcast", event); + await publish("Broadcast", event, relays); setBroadcasting(false); }; @@ -72,7 +71,7 @@ function EventRow({ } export default function TimelineHealth({ timeline, loader }: { loader: TimelineLoader; timeline: NostrEvent[] }) { - const relays = Array.from(Object.keys(loader.relays)); + const relays = loader.relays.map((r) => r.url); return ( <> diff --git a/src/providers/global/publish-provider.tsx b/src/providers/global/publish-provider.tsx index abe6c9333..985c53577 100644 --- a/src/providers/global/publish-provider.tsx +++ b/src/providers/global/publish-provider.tsx @@ -18,6 +18,7 @@ import { eventStore } from "../../services/event-store"; import { addPubkeyRelayHints } from "../../helpers/nostr/post"; import useCurrentAccount from "../../hooks/use-current-account"; import { useUserOutbox } from "../../hooks/use-user-mailboxes"; +import { addSeenRelay } from "applesauce-core/helpers"; type PublishContextType = { log: PublishAction[]; @@ -116,6 +117,10 @@ export default function PublishProvider({ children }: PropsWithChildren) { const pub = new PublishAction(label, relays, signed); setLog((arr) => arr.concat(pub)); + pub.onResult.subscribe((result) => { + if (result.success) addSeenRelay(signed, result.relay.url); + }); + // send it to the local relay if (localRelay) localRelay.publish(signed);