diff --git a/src/assistant.js b/src/assistant.js index ee2e4c576..cb302e100 100644 --- a/src/assistant.js +++ b/src/assistant.js @@ -107,6 +107,7 @@ export async function openAssistantForm({ let lastTask = null modalMountPoint.addEventListener('cancel', () => { + cancelTaskPolling() app.unmount() reject(new Error('User cancellation')) }) @@ -312,6 +313,7 @@ export async function pollTask(taskId, obj, callback = updateTask) { console.debug('[assistant] poll request failed', error) if (error.status === 404) { clearInterval(window.assistantPollTimerId) + window.assistantPollTimerId = null reject(new Error('task-not-found')) return } @@ -521,6 +523,7 @@ export async function openAssistantTask( let lastTask = task modalMountPoint.addEventListener('cancel', () => { + cancelTaskPolling() app.unmount() }) modalMountPoint.addEventListener('submit', (data) => { diff --git a/src/components/ChattyLLM/ChattyLLMInputForm.vue b/src/components/ChattyLLM/ChattyLLMInputForm.vue index 49407662e..592ac86f2 100644 --- a/src/components/ChattyLLM/ChattyLLMInputForm.vue +++ b/src/components/ChattyLLM/ChattyLLMInputForm.vue @@ -183,7 +183,7 @@ import InputArea from './InputArea.vue' import NoSession from './NoSession.vue' import AgencyConfirmation from './AgencyConfirmation.vue' -import axios from '@nextcloud/axios' +import axios, { isCancel } from '@nextcloud/axios' import { showError } from '@nextcloud/dialogs' import { generateUrl, generateOcsUrl } from '@nextcloud/router' import { loadState } from '@nextcloud/initial-state' @@ -345,7 +345,7 @@ export default { }, }, - onDestroy() { + beforeUnmount() { if (this.pollMessageGenerationTimerId) { clearInterval(this.pollMessageGenerationTimerId) } @@ -591,7 +591,7 @@ export default { this.loading.initialMessages = false this.messagesAxiosController = null } catch (error) { - if (axios.isCancel(error)) { + if (isCancel(error)) { console.debug('fetchMessages cancelled') return }