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 () => { const initNewChat = async () => {
if (currentRequestId !== null) {
await cancelChatCompletion(localStorage.token, currentRequestId);
currentRequestId = null;
}
window.history.replaceState(history.state, '', `/`); window.history.replaceState(history.state, '', `/`);
console.log('initNewChat'); console.log('initNewChat');

View file

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