Skip to content

Commit 08c1af1

Browse files
committed
fix: update finished task status in task list
Signed-off-by: Edward Ly <contact@edward.ly>
1 parent 4e6e2c5 commit 08c1af1

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/assistant.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import { TASK_STATUS_STRING } from './constants.js'
77
import { showError } from '@nextcloud/dialogs'
8+
import { emit } from '@nextcloud/event-bus'
89

910
window.assistantPollTimerId = null
1011

@@ -134,6 +135,7 @@ export async function openAssistantForm({
134135
resolve(finishedTask)
135136
view.loading = false
136137
view.showSyncTaskRunning = false
138+
emit('assistant:task:updated', finishedTask)
137139
}).catch(error => {
138140
console.debug('[assistant] poll error', error)
139141
})
@@ -205,6 +207,7 @@ export async function openAssistantForm({
205207
// resolve(finishedTask)
206208
view.loading = false
207209
view.showSyncTaskRunning = false
210+
emit('assistant:task:updated', finishedTask)
208211
}).catch(error => {
209212
console.debug('[assistant] poll error', error)
210213
})
@@ -508,6 +511,7 @@ export async function openAssistantTask(
508511
// resolve(finishedTask)
509512
view.loading = false
510513
view.showSyncTaskRunning = false
514+
emit('assistant:task:updated', finishedTask)
511515
}).catch(error => {
512516
console.debug('[assistant] poll error', error)
513517
view.outputs = null
@@ -577,6 +581,7 @@ export async function openAssistantTask(
577581
// resolve(finishedTask)
578582
view.loading = false
579583
view.showSyncTaskRunning = false
584+
emit('assistant:task:updated', finishedTask)
580585
}).catch(error => {
581586
console.debug('[assistant] poll error', error)
582587
})

src/components/TaskList.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import TaskListItem from './TaskListItem.vue'
3636
import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'
3737
3838
import axios from '@nextcloud/axios'
39+
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
3940
import { generateOcsUrl } from '@nextcloud/router'
4041
4142
import { TASK_STATUS_STRING } from '../constants.js'
@@ -105,6 +106,11 @@ export default {
105106
106107
mounted() {
107108
this.getTasks()
109+
subscribe('assistant:task:updated', this.updateTask)
110+
},
111+
112+
beforeDestroy() {
113+
unsubscribe('assistant:task:updated', this.updateTask)
108114
},
109115
110116
methods: {
@@ -124,6 +130,12 @@ export default {
124130
this.$emit('update:loading', false)
125131
})
126132
},
133+
updateTask(task) {
134+
const taskToUpdate = this.tasks.find(t => t.id === task.id)
135+
if (taskToUpdate) {
136+
Object.assign(taskToUpdate, task)
137+
}
138+
},
127139
onTaskDelete(task) {
128140
const url = generateOcsUrl('taskprocessing/task/{id}', { id: task.id })
129141
axios.delete(url).then(response => {

src/views/AssistantPage.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import NcAppContent from '@nextcloud/vue/dist/Components/NcAppContent.js'
3636
import AssistantTextProcessingForm from '../components/AssistantTextProcessingForm.vue'
3737
3838
import { showError } from '@nextcloud/dialogs'
39+
import { emit } from '@nextcloud/event-bus'
3940
import { loadState } from '@nextcloud/initial-state'
4041
import {
4142
cancelTask,
@@ -130,6 +131,7 @@ export default {
130131
}
131132
this.loading = false
132133
this.showSyncTaskRunning = false
134+
emit('assistant:task:updated', finishedTask)
133135
}).catch(error => {
134136
console.debug('[assistant] poll error', error)
135137
})
@@ -194,6 +196,7 @@ export default {
194196
// resolve(finishedTask)
195197
this.loading = false
196198
this.showSyncTaskRunning = false
199+
emit('assistant:task:updated', finishedTask)
197200
}).catch(error => {
198201
console.debug('Assistant poll error', error)
199202
})

0 commit comments

Comments
 (0)