fix(telegram): load chats/listeners before expanding to fix slide animation height
This commit is contained in:
@@ -81,13 +81,14 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleSection(botId: number, section: string) {
|
async function toggleSection(botId: number, section: string) {
|
||||||
if (expandedSection[botId] === section) {
|
if (expandedSection[botId] === section) {
|
||||||
expandedSection = { ...expandedSection, [botId]: '' };
|
expandedSection = { ...expandedSection, [botId]: '' };
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (section === 'chats' && !chats[botId]) await loadChats(botId);
|
||||||
|
else if (section === 'listeners' && !botListenerStatus[botId]) await loadListenerStatus(botId);
|
||||||
expandedSection = { ...expandedSection, [botId]: section };
|
expandedSection = { ...expandedSection, [botId]: section };
|
||||||
if (section === 'chats') loadChats(botId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadChats(botId: number) {
|
async function loadChats(botId: number) {
|
||||||
@@ -344,12 +345,14 @@
|
|||||||
<div class="flex items-center gap-1 flex-shrink-0 flex-wrap">
|
<div class="flex items-center gap-1 flex-shrink-0 flex-wrap">
|
||||||
<IconButton icon="mdiPencil" title={t('common.edit')} onclick={() => editBot(bot)} />
|
<IconButton icon="mdiPencil" title={t('common.edit')} onclick={() => editBot(bot)} />
|
||||||
<button onclick={() => toggleSection(bot.id, 'chats')}
|
<button onclick={() => toggleSection(bot.id, 'chats')}
|
||||||
class="text-xs text-[var(--color-muted-foreground)] hover:underline px-2 py-1 whitespace-nowrap">
|
disabled={chatsLoading[bot.id]}
|
||||||
{t('telegramBot.chats')} {expandedSection[bot.id] === 'chats' ? '▲' : '▼'}
|
class="text-xs text-[var(--color-muted-foreground)] hover:underline px-2 py-1 whitespace-nowrap disabled:opacity-50">
|
||||||
|
{t('telegramBot.chats')} {chatsLoading[bot.id] ? '…' : expandedSection[bot.id] === 'chats' ? '▲' : '▼'}
|
||||||
</button>
|
</button>
|
||||||
<button onclick={() => { toggleSection(bot.id, 'listeners'); if (expandedSection[bot.id] === 'listeners') loadListenerStatus(bot.id); }}
|
<button onclick={() => toggleSection(bot.id, 'listeners')}
|
||||||
class="text-xs text-[var(--color-muted-foreground)] hover:underline px-2 py-1 whitespace-nowrap">
|
disabled={botListenerLoading[bot.id]}
|
||||||
{t('commandTracker.listeners')} {expandedSection[bot.id] === 'listeners' ? '▲' : '▼'}
|
class="text-xs text-[var(--color-muted-foreground)] hover:underline px-2 py-1 whitespace-nowrap disabled:opacity-50">
|
||||||
|
{t('commandTracker.listeners')} {botListenerLoading[bot.id] ? '…' : expandedSection[bot.id] === 'listeners' ? '▲' : '▼'}
|
||||||
</button>
|
</button>
|
||||||
<IconButton icon="mdiSync" title={t('telegramBot.syncCommands')} onclick={() => syncCommands(bot.id)} disabled={modeChanging[bot.id]} />
|
<IconButton icon="mdiSync" title={t('telegramBot.syncCommands')} onclick={() => syncCommands(bot.id)} disabled={modeChanging[bot.id]} />
|
||||||
<IconButton icon="mdiDelete" title={t('common.delete')} onclick={() => remove(bot.id)} variant="danger" />
|
<IconButton icon="mdiDelete" title={t('common.delete')} onclick={() => remove(bot.id)} variant="danger" />
|
||||||
|
|||||||
Reference in New Issue
Block a user