fix: cancel chat generation on route change

This commit is contained in:
Timothy J. Baek 2024-01-17 19:42:40 -08:00
parent b8337db9d5
commit 981ec89e15
2 changed files with 11 additions and 1 deletions

View File

@ -80,6 +80,11 @@
//////////////////////////
const initNewChat = async () => {
if (currentRequestId !== null) {
await cancelChatCompletion(localStorage.token, currentRequestId);
currentRequestId = null;
}
window.history.replaceState(history.state, '', `/`);
console.log('initNewChat');

View File

@ -705,7 +705,12 @@
<Navbar
{title}
shareEnabled={messages.length > 0}
initNewChat={() => {
initNewChat={async () => {
if (currentRequestId !== null) {
await cancelChatCompletion(localStorage.token, currentRequestId);
currentRequestId = null;
}
goto('/');
}}
/>