From 228d9cc301f3a2029b31b5f87e00993df245121c Mon Sep 17 00:00:00 2001 From: advplyr Date: Wed, 18 May 2022 16:33:24 -0500 Subject: [PATCH] Fix:Library scan toasts --- .../components/app/BookShelfCategorized.vue | 10 +++++++++- client/components/app/LazyBookshelf.vue | 10 +++++++++- .../components/tables/library/LibraryItem.vue | 20 +++++++++++++++++-- client/store/libraries.js | 7 +------ 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/client/components/app/BookShelfCategorized.vue b/client/components/app/BookShelfCategorized.vue index 04156442..beabb150 100644 --- a/client/components/app/BookShelfCategorized.vue +++ b/client/components/app/BookShelfCategorized.vue @@ -190,7 +190,15 @@ export default { }, settingsUpdated(settings) {}, scan() { - this.$store.dispatch('libraries/requestLibraryScan', { libraryId: this.$store.state.libraries.currentLibraryId }) + this.$store + .dispatch('libraries/requestLibraryScan', { libraryId: this.$store.state.libraries.currentLibraryId }) + .then(() => { + this.$toast.success('Library scan started') + }) + .catch((error) => { + console.error('Failed to start scan', error) + this.$toast.error('Failed to start scan') + }) }, libraryItemAdded(libraryItem) { console.log('libraryItem added', libraryItem) diff --git a/client/components/app/LazyBookshelf.vue b/client/components/app/LazyBookshelf.vue index 0f0f1a4c..53011faa 100644 --- a/client/components/app/LazyBookshelf.vue +++ b/client/components/app/LazyBookshelf.vue @@ -605,7 +605,15 @@ export default { } }, scan() { - this.$store.dispatch('libraries/requestLibraryScan', { libraryId: this.currentLibraryId }) + this.$store + .dispatch('libraries/requestLibraryScan', { libraryId: this.currentLibraryId }) + .then(() => { + this.$toast.success('Library scan started') + }) + .catch((error) => { + console.error('Failed to start scan', error) + this.$toast.error('Failed to start scan') + }) } }, mounted() { diff --git a/client/components/tables/library/LibraryItem.vue b/client/components/tables/library/LibraryItem.vue index 1cfa7274..8be8c8ba 100644 --- a/client/components/tables/library/LibraryItem.vue +++ b/client/components/tables/library/LibraryItem.vue @@ -73,10 +73,26 @@ export default { this.$emit('edit', this.library) }, scan() { - this.$store.dispatch('libraries/requestLibraryScan', { libraryId: this.library.id }) + this.$store + .dispatch('libraries/requestLibraryScan', { libraryId: this.library.id }) + .then(() => { + this.$toast.success('Library scan started') + }) + .catch((error) => { + console.error('Failed to start scan', error) + this.$toast.error('Failed to start scan') + }) }, forceScan() { - this.$store.dispatch('libraries/requestLibraryScan', { libraryId: this.library.id, force: 1 }) + this.$store + .dispatch('libraries/requestLibraryScan', { libraryId: this.library.id, force: 1 }) + .then(() => { + this.$toast.success('Library scan started') + }) + .catch((error) => { + console.error('Failed to start scan', error) + this.$toast.error('Failed to start scan') + }) }, deleteClick() { if (this.isMain) return diff --git a/client/store/libraries.js b/client/store/libraries.js index 20f32cd1..ded8d5ee 100644 --- a/client/store/libraries.js +++ b/client/store/libraries.js @@ -47,12 +47,7 @@ export const getters = { export const actions = { requestLibraryScan({ state, commit }, { libraryId, force }) { - this.$axios.$get(`/api/libraries/${libraryId}/scan`, { params: { force } }).then(() => { - this.$toast.success('Library scan started') - }).catch((error) => { - console.error('Failed to start scan', error) - this.$toast.error('Failed to start scan') - }) + return this.$axios.$get(`/api/libraries/${libraryId}/scan`, { params: { force } }) }, loadFolders({ state, commit }) { if (state.folders.length) {