Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: get notification request status when loading running task
Signed-off-by: Edward Ly <[email protected]>
  • Loading branch information
edward-ly committed Jun 18, 2025
commit 8041524aa098eddec621ab9201d59e09d4a48b6a
21 changes: 21 additions & 0 deletions src/assistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export async function openAssistantForm({
console.debug('[assistant] loading task', task)
cancelTaskPolling()
view.showSyncTaskRunning = false
view.isNotifyEnabled = false

view.selectedTaskTypeId = task.type
view.inputs = task.input
Expand All @@ -177,6 +178,12 @@ export async function openAssistantForm({
return
}

getNotifyReady(task.id).then(response => {
view.isNotifyEnabled = !!response.data?.ocs?.data?.id
}).catch(error => {
console.error('[assistant] get task notification status error', error)
})

view.loading = true
view.showSyncTaskRunning = true
view.progress = null
Expand Down Expand Up @@ -277,6 +284,13 @@ export async function getTask(taskId) {
return axios.get(url, { signal: window.assistantAbortController.signal })
}

export async function getNotifyReady(taskId) {
const { default: axios } = await import('@nextcloud/axios')
const { generateOcsUrl } = await import('@nextcloud/router')
const url = generateOcsUrl('/apps/assistant/api/v1/task/{taskId}/notify', { taskId })
return axios.get(url, {})
}

export async function setNotifyReady(taskId, enable) {
const { default: axios } = await import('@nextcloud/axios')
const { generateOcsUrl } = await import('@nextcloud/router')
Expand Down Expand Up @@ -515,6 +529,7 @@ export async function openAssistantTask(
view.$on('load-task', (task) => {
cancelTaskPolling()
view.showSyncTaskRunning = false
view.isNotifyEnabled = false

view.selectedTaskTypeId = task.type
view.inputs = task.input
Expand All @@ -535,6 +550,12 @@ export async function openAssistantTask(
return
}

getNotifyReady(task.id).then(response => {
view.isNotifyEnabled = !!response.data?.ocs?.data?.id
}).catch(error => {
console.error('[assistant] get task notification status error', error)
})

view.loading = true
view.showSyncTaskRunning = true
view.progress = null
Expand Down