[feat] added abort

This commit is contained in:
kwaroran
2023-07-23 00:26:07 +09:00
parent 1b34cd605a
commit 704b03b3a8
3 changed files with 73 additions and 79 deletions

View File

@@ -143,10 +143,13 @@
}
}
let abortController:null|AbortController = null
async function sendChatMain(saveReroll = false) {
messageInput = ''
abortController = new AbortController()
try {
await sendChat()
await sendChat(-1, {signal:abortController.signal})
} catch (error) {
console.error(error)
alertError(`${error}`)
@@ -161,6 +164,13 @@
}
}
function abortChat(){
if(abortController){
console.log('abort')
abortController.abort()
}
}
async function runAutoMode() {
if(autoMode){
autoMode = false
@@ -323,7 +333,7 @@
{#if $doingChat || doingChatInputTranslate}
<div
class="mr-2 bg-selected flex justify-center items-center text-white w-12 h-12 rounded-md hover:bg-green-500 transition-colors">
class="mr-2 bg-selected flex justify-center items-center text-white w-12 h-12 rounded-md hover:bg-green-500 transition-colors" on:click={abortChat}>
<div class="loadmove" class:autoload={autoMode}>
</div>
</div>