Skip to content

Commit

Permalink
show error toast when failing to schedule or to show results of a task
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Veyssier <[email protected]>
  • Loading branch information
julien-nc committed Aug 9, 2023
1 parent f7d7f9a commit 368bdd9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/assistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,14 @@ export function handleNotification(event) {
async function showResults(taskId) {
const { default: axios } = await import(/* webpackChunkName: "axios-lazy" */'@nextcloud/axios')
const { generateOcsUrl } = await import(/* webpackChunkName: "router-lazy" */'@nextcloud/router')
const { showError } = await import(/* webpackChunkName: "dialogs-lazy" */'@nextcloud/dialogs')
const url = generateOcsUrl('textprocessing/task/{taskId}', { taskId })
axios.get(url).then(response => {
console.debug('showing results for task', response.data.ocs.data.task)
openAssistantResult(response.data.ocs.data.task)
}).catch(error => {
console.error(error)
showError(t('textprocessing_assistant', 'This task does not exist or has been cleaned up'))
})
}

Expand All @@ -157,6 +159,7 @@ async function showResults(taskId) {
* @return {Promise<void>}
*/
export async function openAssistantResult(task) {
const { showError } = await import(/* webpackChunkName: "dialogs-lazy" */'@nextcloud/dialogs')
const { default: Vue } = await import(/* webpackChunkName: "vue-lazy" */'vue')
const { default: AssistantModal } = await import(/* webpackChunkName: "assistant-modal-lazy" */'./components/AssistantModal.vue')
Vue.mixin({ methods: { t, n } })
Expand Down Expand Up @@ -189,6 +192,7 @@ export async function openAssistantResult(task) {
.catch(error => {
view.$destroy()
console.error('Assistant scheduling error', error)
showError(t('textprocessing_assistant', 'Failed to schedule the task'))
})
})
}
Expand Down

0 comments on commit 368bdd9

Please sign in to comment.