Skip to content

Commit 4e6e2c5

Browse files
committed
feat: get notification request status when loading running task
Signed-off-by: Edward Ly <contact@edward.ly>
1 parent 32d5e73 commit 4e6e2c5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/assistant.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ export async function openAssistantForm({
157157
console.debug('[assistant] loading task', task)
158158
cancelTaskPolling()
159159
view.showSyncTaskRunning = false
160+
view.isNotifyEnabled = false
160161

161162
view.selectedTaskTypeId = task.type
162163
view.inputs = task.input
@@ -177,6 +178,12 @@ export async function openAssistantForm({
177178
return
178179
}
179180

181+
getNotifyReady(task.id).then(response => {
182+
view.isNotifyEnabled = !!response.data?.ocs?.data?.id
183+
}).catch(error => {
184+
console.error('[assistant] get task notification status error', error)
185+
})
186+
180187
view.loading = true
181188
view.showSyncTaskRunning = true
182189
view.progress = null
@@ -277,6 +284,13 @@ export async function getTask(taskId) {
277284
return axios.get(url, { signal: window.assistantAbortController.signal })
278285
}
279286

287+
export async function getNotifyReady(taskId) {
288+
const { default: axios } = await import('@nextcloud/axios')
289+
const { generateOcsUrl } = await import('@nextcloud/router')
290+
const url = generateOcsUrl('/apps/assistant/api/v1/task/{taskId}/notify', { taskId })
291+
return axios.get(url, {})
292+
}
293+
280294
export async function setNotifyReady(taskId, enable) {
281295
const { default: axios } = await import('@nextcloud/axios')
282296
const { generateOcsUrl } = await import('@nextcloud/router')
@@ -515,6 +529,7 @@ export async function openAssistantTask(
515529
view.$on('load-task', (task) => {
516530
cancelTaskPolling()
517531
view.showSyncTaskRunning = false
532+
view.isNotifyEnabled = false
518533

519534
view.selectedTaskTypeId = task.type
520535
view.inputs = task.input
@@ -535,6 +550,12 @@ export async function openAssistantTask(
535550
return
536551
}
537552

553+
getNotifyReady(task.id).then(response => {
554+
view.isNotifyEnabled = !!response.data?.ocs?.data?.id
555+
}).catch(error => {
556+
console.error('[assistant] get task notification status error', error)
557+
})
558+
538559
view.loading = true
539560
view.showSyncTaskRunning = true
540561
view.progress = null

0 commit comments

Comments
 (0)