diff --git a/src/components/navigation/AppNavigationBoard.vue b/src/components/navigation/AppNavigationBoard.vue index 7c27e7cb4..73c24740e 100644 --- a/src/components/navigation/AppNavigationBoard.vue +++ b/src/components/navigation/AppNavigationBoard.vue @@ -131,19 +131,18 @@ export default { }) actions.push({ - action: async () => { + action: async() => { this.hideMenu() this.loading = true try { const newBoard = await this.$store.dispatch('cloneBoard', this.board) - this.loading = false const route = this.routeTo route.params.id = newBoard.id this.$router.push(route) - } - catch { + } catch (e) { OC.Notification.showTemporary(t('deck', 'An error occurred')) + console.error(e) } }, icon: 'icon-clone', diff --git a/src/services/BoardApi.js b/src/services/BoardApi.js index ff780ce5d..336b638ad 100644 --- a/src/services/BoardApi.js +++ b/src/services/BoardApi.js @@ -135,19 +135,13 @@ export class BoardApi { }) } - cloneBoard(board) { - return axios.post(this.url(`/boards/${board.id}/clone`)) - .then( - (response) => { - return Promise.resolve(response.data) - }, - (err) => { - return Promise.reject(err) - } - ) - .catch((err) => { - return Promise.reject(err) - }) + async cloneBoard(board) { + try { + let response = await axios.post(this.url(`/boards/${board.id}/clone`)) + return response.data + } catch (err) { + return err + } } // Label API Calls diff --git a/src/store/main.js b/src/store/main.js index fb67ff39c..82b22bd3e 100644 --- a/src/store/main.js +++ b/src/store/main.js @@ -280,17 +280,14 @@ export default new Vuex.Store({ commit('addBoard', board) }) }, - cloneBoard({ commit }, boardData) { - return new Promise((resolve, reject) => { - apiClient.cloneBoard(boardData) - .then((board) => { - commit('cloneBoard', board) - resolve(board) - }) - .catch((err) => { - return reject(err) - }) - }) + async cloneBoard({ commit }, boardData) { + try { + let newBoard = await apiClient.cloneBoard(boardData) + commit('cloneBoard', newBoard) + return newBoard + } catch (err) { + return err + } }, removeBoard({ commit }, board) { commit('removeBoard', board)