diff --git a/src/components/AppDialog.tsx b/src/components/AppDialog.tsx index cc03d5f6..4d75ae76 100644 --- a/src/components/AppDialog.tsx +++ b/src/components/AppDialog.tsx @@ -204,6 +204,7 @@ export function AppDialog({ projectId, open, onOpenChange }: AppDialogProps) { const [formData, setFormData] = useState(emptyFormData(projectId)); const [isSaving, setIsSaving] = useState(false); const [submitted, setSubmitted] = useState(false); + const [confirmDelete, setConfirmDelete] = useState(false); const [newKind, setNewKind] = useState(''); const [newHandlerUrl, setNewHandlerUrl] = useState(''); const [newHandlerType, setNewHandlerType] = useState(''); @@ -404,6 +405,37 @@ export function AppDialog({ projectId, open, onOpenChange }: AppDialogProps) { } }; + const handleDelete = async () => { + if (!event) return; + setIsSaving(true); + try { + // Publish NIP-09 deletion event + await publishEvent({ + kind: 5, + content: 'Deleted app', + tags: [['e', event.id], ['a', `31990:${event.pubkey}:${formData.dTag}`]], + }); + + // Remove the local app config + const dotAI = new DotAI(fs, cwd); + await dotAI.writeAppConfig({ a: '' }); + + await queryClient.invalidateQueries({ queryKey: ['app-event'] }); + + toast({ title: 'App deleted', description: `"${formData.name}" has been deleted.` }); + onOpenChange(false); + } catch (error) { + toast({ + title: 'Failed to delete', + description: error instanceof Error ? error.message : 'An unexpected error occurred', + variant: 'destructive', + }); + } finally { + setIsSaving(false); + setConfirmDelete(false); + } + }; + if (!user) { return ( @@ -685,6 +717,47 @@ export function AppDialog({ projectId, open, onOpenChange }: AppDialogProps) { URL patterns where {''} will be replaced with the NIP-19 entity.

+ {/* Delete App */} + {hasApp && ( +
+ {confirmDelete ? ( +
+

Are you sure? This will publish a deletion event to Nostr.

+
+ + +
+
+ ) : ( + + )} +
+ )}