Add delete task functionality for task authors
Added ability for task authors to delete their own tasks from the expanded view in the task feed. **Features:** - Delete button visible only to task author in expanded task view - Confirmation dialog with destructive styling - Publishes NIP-09 deletion event (kind 5) with 'a' tag referencing the task's event address (kind:pubkey:d-tag format) - Real-time deletion handling via FeedService routing - Optimistic local state update for immediate UI feedback **Implementation:** - Added deleteTask() method to ScheduledEventService - Added handleTaskDeletion() for processing incoming deletion events - Updated FeedService to route kind 31922 deletions to ScheduledEventService - Added delete button and dialog flow to ScheduledEventCard component - Integrated with existing confirmation dialog pattern **Permissions:** - Only task authors can delete tasks (enforced by isAuthor check) - NIP-09 validation: relays only accept deletion from event author - Pubkey verification in handleTaskDeletion() **Testing:** - Created tasks and verified delete button appears for author only - Confirmed deletion removes task from UI immediately - Verified deletion persists after refresh - Tested with multiple users - others cannot delete 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
8f05f4ec7c
commit
3b8c82514a
5 changed files with 185 additions and 2 deletions
|
|
@ -107,6 +107,7 @@ const {
|
|||
startTask,
|
||||
completeEvent,
|
||||
unclaimTask,
|
||||
deleteTask,
|
||||
allCompletions
|
||||
} = useScheduledEvents()
|
||||
|
||||
|
|
@ -301,6 +302,15 @@ async function onUnclaimTask(event: ScheduledEvent, occurrence?: string) {
|
|||
}
|
||||
}
|
||||
|
||||
async function onDeleteTask(event: ScheduledEvent) {
|
||||
console.log('🗑️ NostrFeed: Deleting task:', event.title)
|
||||
try {
|
||||
await deleteTask(event)
|
||||
} catch (error) {
|
||||
console.error('❌ Failed to delete task:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// Handle collapse toggle with cascading behavior
|
||||
function onToggleCollapse(postId: string) {
|
||||
const newCollapsed = new Set(collapsedPosts.value)
|
||||
|
|
@ -555,6 +565,7 @@ function cancelDelete() {
|
|||
@start-task="onStartTask"
|
||||
@complete-task="onCompleteTask"
|
||||
@unclaim-task="onUnclaimTask"
|
||||
@delete-task="onDeleteTask"
|
||||
/>
|
||||
</div>
|
||||
<div v-else class="text-center py-3 text-muted-foreground text-sm px-4">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue