mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Check for chat changed before displaying welcome panel
This commit is contained in:
@ -54,7 +54,14 @@ export async function openWelcomeScreen() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await sendWelcomePanel();
|
const recentChats = await getRecentChats();
|
||||||
|
const chatAfterFetch = getCurrentChatId();
|
||||||
|
if (chatAfterFetch !== currentChatId) {
|
||||||
|
console.debug('Chat changed while fetching recent chats.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await sendWelcomePanel(recentChats);
|
||||||
sendAssistantMessage();
|
sendAssistantMessage();
|
||||||
sendWelcomePrompt();
|
sendWelcomePrompt();
|
||||||
}
|
}
|
||||||
@ -86,7 +93,11 @@ function sendWelcomePrompt() {
|
|||||||
addOneMessage(message, { scroll: false });
|
addOneMessage(message, { scroll: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sendWelcomePanel() {
|
/**
|
||||||
|
* Sends the welcome panel to the chat.
|
||||||
|
* @param {RecentChat[]} chats List of recent chats
|
||||||
|
*/
|
||||||
|
async function sendWelcomePanel(chats) {
|
||||||
try {
|
try {
|
||||||
const chatElement = document.getElementById('chat');
|
const chatElement = document.getElementById('chat');
|
||||||
const sendTextArea = document.getElementById('send_textarea');
|
const sendTextArea = document.getElementById('send_textarea');
|
||||||
@ -94,7 +105,6 @@ async function sendWelcomePanel() {
|
|||||||
console.error('Chat element not found');
|
console.error('Chat element not found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const chats = await getRecentChats();
|
|
||||||
const templateData = {
|
const templateData = {
|
||||||
chats,
|
chats,
|
||||||
empty: !chats.length,
|
empty: !chats.length,
|
||||||
|
Reference in New Issue
Block a user