mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-10-10 12:53:14 +02:00
publish additions to mailboxes
This commit is contained in:
@@ -26,11 +26,10 @@ import { useCallback } from "react";
|
|||||||
import { NostrEvent } from "../../types/nostr-event";
|
import { NostrEvent } from "../../types/nostr-event";
|
||||||
import { addRelayModeToMailbox, removeRelayModeFromMailbox } from "../../helpers/nostr/mailbox";
|
import { addRelayModeToMailbox, removeRelayModeFromMailbox } from "../../helpers/nostr/mailbox";
|
||||||
import useAsyncErrorHandler from "../../hooks/use-async-error-handler";
|
import useAsyncErrorHandler from "../../hooks/use-async-error-handler";
|
||||||
import { useSigningContext } from "../../providers/global/signing-provider";
|
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { safeRelayUrl } from "../../helpers/relay";
|
import { safeRelayUrl } from "../../helpers/relay";
|
||||||
import replaceableEventLoaderService from "../../services/replaceable-event-requester";
|
|
||||||
import { usePublishEvent } from "../../providers/global/publish-provider";
|
import { usePublishEvent } from "../../providers/global/publish-provider";
|
||||||
|
import RelaySet from "../../classes/relay-set";
|
||||||
|
|
||||||
function RelayLine({ relay, mode, list }: { relay: string; mode: RelayMode; list?: NostrEvent }) {
|
function RelayLine({ relay, mode, list }: { relay: string; mode: RelayMode; list?: NostrEvent }) {
|
||||||
const publish = usePublishEvent();
|
const publish = usePublishEvent();
|
||||||
@@ -83,22 +82,16 @@ function AddRelayForm({ onSubmit }: { onSubmit: (url: string) => void }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function MailboxesPage() {
|
function MailboxesPage() {
|
||||||
const toast = useToast();
|
|
||||||
const account = useCurrentAccount()!;
|
const account = useCurrentAccount()!;
|
||||||
const { inbox, outbox, event } = useUserMailboxes(account.pubkey, { alwaysRequest: true }) || {};
|
const publish = usePublishEvent();
|
||||||
|
const { inbox, outbox, event } = useUserMailboxes(account.pubkey, { alwaysRequest: true, ignoreCache: true }) || {};
|
||||||
|
|
||||||
const { requestSignature } = useSigningContext();
|
|
||||||
const addRelay = useCallback(
|
const addRelay = useCallback(
|
||||||
async (relay: string, mode: RelayMode) => {
|
async (relay: string, mode: RelayMode) => {
|
||||||
try {
|
|
||||||
const draft = addRelayModeToMailbox(event ?? undefined, relay, mode);
|
const draft = addRelayModeToMailbox(event ?? undefined, relay, mode);
|
||||||
const signed = await requestSignature(draft);
|
await publish("Add Relay", draft, event ? RelaySet.fromNIP65Event(event, RelayMode.ALL) : undefined);
|
||||||
replaceableEventLoaderService.handleEvent(signed);
|
|
||||||
} catch (e) {
|
|
||||||
if (e instanceof Error) toast({ status: "error", description: e.message });
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
[event, requestSignature],
|
[event],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Reference in New Issue
Block a user