Add removeInvitation to the invitation screen

This commit is contained in:
2026-06-08 13:22:13 +02:00
parent 69adee180a
commit bca736dab4
3 changed files with 57 additions and 0 deletions

View File

@@ -63,6 +63,7 @@ const actionItems: ListItemData<string>[] = [
{ key: 'sign', label: 'Sign Transaction', value: 'sign' },
{ key: 'broadcast', label: 'Broadcast Transaction', value: 'broadcast' },
{ key: 'copy', label: 'Copy Invitation ID', value: 'copy' },
{ key: 'delete', label: 'Delete Invitation', value: 'delete' },
];
/**
@@ -354,6 +355,28 @@ export function InvitationScreen(): React.ReactElement {
}
}, [selectedInvitation, showInfo, showError, setStatus]);
/**
* Delete the selected invitation from both our SQLite db and the engine's db
* NOTE: This uses methods marked "DANGEROUSLY" internally, and may change in the future.
*/
const deleteInvitation = useCallback(async () => {
if (!selectedInvitation) return;
setIsLoading(true)
setStatus('Removing invitation...')
try {
await selectedInvitation.delete();
showInfo('Invitation successfully deleted')
setStatus('Ready')
} catch (error) {
showError(`Failed to delete invitation: ${error instanceof Error ? error.message : String(error)}`)
} finally {
setIsLoading(false)
setStatus('Ready')
}
})
const copyId = useCallback(async () => {
if (!selectedInvitation) {
showError('No invitation selected');
@@ -509,6 +532,9 @@ export function InvitationScreen(): React.ReactElement {
case 'broadcast':
broadcastTransaction();
break;
case 'delete':
deleteInvitation();
break;
}
}, [selectedInvitation, copyId, acceptInvitation, fillRequirements, signInvitation, broadcastTransaction, navigate]);