Skip to content

Commit 072e7ec

Browse files
authored
Merge pull request #356 from nextcloud/fix/355/stop-polling
Fix stop polling when needed
2 parents e65d493 + 52ac775 commit 072e7ec

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/assistant.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export async function openAssistantForm({
107107
let lastTask = null
108108

109109
modalMountPoint.addEventListener('cancel', () => {
110+
cancelTaskPolling()
110111
app.unmount()
111112
reject(new Error('User cancellation'))
112113
})
@@ -312,6 +313,7 @@ export async function pollTask(taskId, obj, callback = updateTask) {
312313
console.debug('[assistant] poll request failed', error)
313314
if (error.status === 404) {
314315
clearInterval(window.assistantPollTimerId)
316+
window.assistantPollTimerId = null
315317
reject(new Error('task-not-found'))
316318
return
317319
}
@@ -521,6 +523,7 @@ export async function openAssistantTask(
521523
let lastTask = task
522524

523525
modalMountPoint.addEventListener('cancel', () => {
526+
cancelTaskPolling()
524527
app.unmount()
525528
})
526529
modalMountPoint.addEventListener('submit', (data) => {

src/components/ChattyLLM/ChattyLLMInputForm.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ import InputArea from './InputArea.vue'
183183
import NoSession from './NoSession.vue'
184184
import AgencyConfirmation from './AgencyConfirmation.vue'
185185
186-
import axios from '@nextcloud/axios'
186+
import axios, { isCancel } from '@nextcloud/axios'
187187
import { showError } from '@nextcloud/dialogs'
188188
import { generateUrl, generateOcsUrl } from '@nextcloud/router'
189189
import { loadState } from '@nextcloud/initial-state'
@@ -345,7 +345,7 @@ export default {
345345
},
346346
},
347347
348-
onDestroy() {
348+
beforeUnmount() {
349349
if (this.pollMessageGenerationTimerId) {
350350
clearInterval(this.pollMessageGenerationTimerId)
351351
}
@@ -591,7 +591,7 @@ export default {
591591
this.loading.initialMessages = false
592592
this.messagesAxiosController = null
593593
} catch (error) {
594-
if (axios.isCancel(error)) {
594+
if (isCancel(error)) {
595595
console.debug('fetchMessages cancelled')
596596
return
597597
}

0 commit comments

Comments
 (0)