From 79ed87e67c07471457b565723128a9742875b7ba Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 30 May 2025 23:40:57 +0200 Subject: [PATCH] useNostrPublish returns the event --- src/hooks/useNostrPublish.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/hooks/useNostrPublish.ts b/src/hooks/useNostrPublish.ts index a940385..316f1ce 100644 --- a/src/hooks/useNostrPublish.ts +++ b/src/hooks/useNostrPublish.ts @@ -1,21 +1,16 @@ import { useNostr } from "@nostrify/react"; -import { useMutation } from "@tanstack/react-query"; +import { useMutation, type UseMutationResult } from "@tanstack/react-query"; import { useCurrentUser } from "./useCurrentUser"; -interface EventTemplate { - kind: number; - content?: string; - tags?: string[][]; - created_at?: number; -} +import type { NostrEvent } from "@nostrify/nostrify"; -export function useNostrPublish() { +export function useNostrPublish(): UseMutationResult { const { nostr } = useNostr(); const { user } = useCurrentUser(); return useMutation({ - mutationFn: async (t: EventTemplate) => { + mutationFn: async (t: Omit) => { if (user) { const tags = t.tags ?? []; @@ -33,6 +28,7 @@ export function useNostrPublish() { }); await nostr.event(event, { signal: AbortSignal.timeout(5000) }); + return event; } else { throw new Error("User is not logged in"); }