From 0e57826ea517e22d242b88b19440e8f75ab9ec06 Mon Sep 17 00:00:00 2001 From: Manuel Lorenzo Date: Tue, 17 Feb 2026 00:29:52 +0100 Subject: [PATCH] fix: await for confirmation before deleting voices and channels --- app/src/components/AudioTab/AudioTab.tsx | 14 ++++++++------ app/src/components/VoicesTab/VoicesTab.tsx | 6 +++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/src/components/AudioTab/AudioTab.tsx b/app/src/components/AudioTab/AudioTab.tsx index f76e99d7..395922c8 100644 --- a/app/src/components/AudioTab/AudioTab.tsx +++ b/app/src/components/AudioTab/AudioTab.tsx @@ -124,6 +124,13 @@ export function AudioTab() { ); } + const handleChannelDelete = async (e, channelId) => { + e.stopPropagation(); + if (await confirm('Delete this channel?')) { + deleteChannel.mutate(channelId); + } + } + const allChannels = channels || []; const allDevices = devices || []; const selectedChannel = selectedChannelId @@ -241,12 +248,7 @@ export function AudioTab() { variant="ghost" size="sm" className="h-8 w-8 p-0" - onClick={(e) => { - e.stopPropagation(); - if (confirm('Delete this channel?')) { - deleteChannel.mutate(channel.id); - } - }} + onClick={(e) => handleChannelDelete(e, channel.id)} > diff --git a/app/src/components/VoicesTab/VoicesTab.tsx b/app/src/components/VoicesTab/VoicesTab.tsx index 12fedef5..c5dbf0a1 100644 --- a/app/src/components/VoicesTab/VoicesTab.tsx +++ b/app/src/components/VoicesTab/VoicesTab.tsx @@ -79,8 +79,8 @@ export function VoicesTab() { setDialogOpen(true); }; - const handleDelete = (profileId: string) => { - if (confirm('Are you sure you want to delete this profile?')) { + const handleProfileDelete = async (profileId: string) => { + if (await confirm('Are you sure you want to delete this profile?')) { deleteProfile.mutate(profileId); } }; @@ -147,7 +147,7 @@ export function VoicesTab() { channels={channels || []} onChannelChange={(channelIds) => handleChannelChange(profile.id, channelIds)} onEdit={() => handleEdit(profile.id)} - onDelete={() => handleDelete(profile.id)} + onDelete={() => handleProfileDelete(profile.id)} /> ))}