Focus on send textarea on opening temp chat
| @@ -30,6 +30,9 @@ import { sortMoments, timestampToMoment } from './utils.js'; | ||
| 30 | 30 | const assistantAvatarKey = 'assistant'; |
| 31 | 31 | const defaultAssistantAvatar = 'default_Assistant.png'; |
| 32 | 32 | |
| 33 | +const DEFAULT_DISPLAYED = 5; | |
| 34 | +const MAX_DISPLAYED = 20; | |
| 35 | + | |
| 33 | 36 | export function getPermanentAssistantAvatar() { |
| 34 | 37 | const assistantAvatar = accountStorage.getItem(assistantAvatarKey); |
| 35 | 38 | if (assistantAvatar === null) { |
| @@ -78,6 +81,7 @@ function sendAssistantMessage() { | ||
| 78 | 81 | async function sendWelcomePanel() { |
| 79 | 82 | try { |
| 80 | 83 | const chatElement = document.getElementById('chat'); |
| 84 | + const sendTextArea = document.getElementById('send_textarea'); | |
| 81 | 85 | if (!chatElement) { |
| 82 | 86 | console.error('Chat element not found'); |
| 83 | 87 | return; |
| @@ -104,7 +108,7 @@ async function sendWelcomePanel() { | ||
| 104 | 108 | }); |
| 105 | 109 | }); |
| 106 | 110 | root.querySelectorAll('.hideRecentChats').forEach((button) => { |
| 107 | 111 | button.addEventListener('click', () => { |
| 108 | 112 | root.classList.add(recentHiddenClass); |
| 109 | 113 | accountStorage.setItem(recentHiddenKey, 'true'); |
| 110 | 114 | }); |
| @@ -134,8 +138,11 @@ async function sendWelcomePanel() { | ||
| 134 | 138 | }); |
| 135 | 139 | }); |
| 136 | 140 | fragment.querySelectorAll('button.openTemporaryChat').forEach((button) => { |
| 137 | 141 | button.addEventListener('click', async () => { |
| 138 | 142 | voidawait newAssistantChat({ temporary: true }); |
| 143 | + if (sendTextArea instanceof HTMLTextAreaElement) { | |
| 144 | + sendTextArea.focus(); | |
| 145 | + } | |
| 139 | 146 | }); |
| 140 | 147 | }); |
| 141 | 148 | fragment.querySelectorAll('.recentChat.group').forEach((groupChat) => { |
| @@ -259,8 +266,8 @@ async function getRecentChats() { | ||
| 259 | 266 | data.sort((a, b) => sortMoments(timestampToMoment(a.last_mes), timestampToMoment(b.last_mes))) |
| 260 | 267 | .map(chat => ({ chat, character: characters.find(x => x.avatar === chat.avatar), group: groups.find(x => x.id === chat.group) })) |
| 261 | 268 | .filter(t => t.character || t.group) |
| 269 | + .slice(0, MAX_DISPLAYED) | |
| 262 | 270 | .forEach(({ chat, character, group }, index) => { |
| 263 | - const DEFAULT_DISPLAYED = 5; | |
| 264 | 271 | const chatTimestamp = timestampToMoment(chat.last_mes); |
| 265 | 272 | chat.char_name = character?.name || group?.name || ''; |
| 266 | 273 | chat.date_short = chatTimestamp.format('l'); |
| @@ -388,7 +395,7 @@ export function initWelcomeScreen() { | ||
| 388 | 395 | eventSource.makeFirst(event, openWelcomeScreen); |
| 389 | 396 | } |
| 390 | 397 | |
| 391 | 398 | eventSource.on(event_types.CHARACTER_MANAGEMENT_DROPDOWN, (target) => { |
| 392 | 399 | if (target !== 'set_as_assistant') { |
| 393 | 400 | return; |
| 394 | 401 | } |