Fix chat row: whole row clickable, fix snack message, stop propagation on delete
All checks were successful
Validate / Hassfest (push) Successful in 3s

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-19 21:51:45 +03:00
parent 482f54d620
commit 0a94f2bc88

View File

@@ -115,9 +115,10 @@
} catch (err: any) { snackError(err.message); } } catch (err: any) { snackError(err.message); }
} }
function copyChatId(chatId: string) { function copyChatId(e: Event, chatId: string) {
e.stopPropagation();
navigator.clipboard.writeText(chatId); navigator.clipboard.writeText(chatId);
snackInfo(t('snack.copied') + ': ' + chatId); snackInfo(`${t('telegramBot.clickToCopy')}: ${chatId}`);
} }
function toggleCommand(botId: number, cmd: string) { function toggleCommand(botId: number, cmd: string) {
@@ -236,16 +237,17 @@
{:else} {:else}
<div class="space-y-1"> <div class="space-y-1">
{#each chats[bot.id] as chat} {#each chats[bot.id] as chat}
<div class="flex items-center justify-between text-sm px-2 py-1 rounded hover:bg-[var(--color-muted)] group"> <div class="flex items-center justify-between text-sm px-2 py-1 rounded hover:bg-[var(--color-muted)] cursor-pointer"
<button class="flex items-center gap-2 text-left cursor-pointer" onclick={(e: MouseEvent) => copyChatId(e, chat.chat_id)}
onclick={() => copyChatId(chat.chat_id)} title={t('telegramBot.clickToCopy')}
title={t('telegramBot.clickToCopy')}> role="button" tabindex="0">
<div class="flex items-center gap-2">
<span class="font-medium">{chat.title || chat.username || 'Unknown'}</span> <span class="font-medium">{chat.title || chat.username || 'Unknown'}</span>
<span class="text-xs px-1.5 py-0.5 rounded bg-[var(--color-muted)] text-[var(--color-muted-foreground)]">{chatTypeLabel(chat.type)}</span> <span class="text-xs px-1.5 py-0.5 rounded bg-[var(--color-muted)] text-[var(--color-muted-foreground)]">{chatTypeLabel(chat.type)}</span>
<span class="text-xs text-[var(--color-muted-foreground)] font-mono">{chat.chat_id}</span> <span class="text-xs text-[var(--color-muted-foreground)] font-mono">{chat.chat_id}</span>
</button> </div>
<IconButton icon="mdiDelete" title={t('common.delete')} size={14} <IconButton icon="mdiDelete" title={t('common.delete')} size={14}
onclick={() => deleteChat(bot.id, chat.id)} variant="danger" /> onclick={(e: MouseEvent) => { e.stopPropagation(); deleteChat(bot.id, chat.id); }} variant="danger" />
</div> </div>
{/each} {/each}
</div> </div>