mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-03-17 21:31:43 +01:00
fix timeline health
This commit is contained in:
parent
5f66729b6f
commit
7d2d8886dc
@ -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<TableRowProps, "children">) {
|
||||
// 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 (
|
||||
<>
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user