From bc603605a723965367f7242df8fdb2226a3520c8 Mon Sep 17 00:00:00 2001 From: kolaente Date: Fri, 29 May 2020 16:34:29 +0200 Subject: [PATCH] Fix error messages when trying to update tasks in kanban if kanban hasn't been opened yet --- src/store/modules/tasks.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/store/modules/tasks.js b/src/store/modules/tasks.js index 4bd9b65a..da66336d 100644 --- a/src/store/modules/tasks.js +++ b/src/store/modules/tasks.js @@ -49,7 +49,11 @@ export default { .then(r => { const t = ctx.rootGetters['kanban/getTaskById'](taskId) if (t.task === null) { - return Promise.reject('Task not found.') + // Don't try further adding a label if the task is not in kanban + // Usually this means the kanban board hasn't been accessed until now. + // Vuex seems to have its difficulties with that, so we just log the error and fail silently. + console.debug('Could not add assignee to task in kanban, task not found', t) + return Promise.resolve(r) } t.task.assignees.push(user) ctx.commit('kanban/setTaskInBucketByIndex', t, {root: true}) @@ -68,7 +72,11 @@ export default { .then(r => { const t = ctx.rootGetters['kanban/getTaskById'](taskId) if (t.task === null) { - return Promise.reject('Task not found.') + // Don't try further adding a label if the task is not in kanban + // Usually this means the kanban board hasn't been accessed until now. + // Vuex seems to have its difficulties with that, so we just log the error and fail silently. + console.debug('Could not remove assignee from task in kanban, task not found', t) + return Promise.resolve(r) } for (const a in t.task.assignees) { @@ -95,7 +103,11 @@ export default { .then(r => { const t = ctx.rootGetters['kanban/getTaskById'](taskId) if (t.task === null) { - return Promise.reject('Task not found.') + // Don't try further adding a label if the task is not in kanban + // Usually this means the kanban board hasn't been accessed until now. + // Vuex seems to have its difficulties with that, so we just log the error and fail silently. + console.debug('Could not add label to task in kanban, task not found', t) + return Promise.resolve(r) } t.task.labels.push(label) ctx.commit('kanban/setTaskInBucketByIndex', t, {root: true}) @@ -115,7 +127,11 @@ export default { .then(r => { const t = ctx.rootGetters['kanban/getTaskById'](taskId) if (t.task === null) { - return Promise.reject('Task not found.') + // Don't try further adding a label if the task is not in kanban + // Usually this means the kanban board hasn't been accessed until now. + // Vuex seems to have its difficulties with that, so we just log the error and fail silently. + console.debug('Could not remove label from task in kanban, task not found', t) + return Promise.resolve(r) } // Remove the label from the list