Fix:Library scan toasts

This commit is contained in:
advplyr 2022-05-18 16:33:24 -05:00
parent 85946dd1d5
commit 228d9cc301
4 changed files with 37 additions and 10 deletions

View File

@ -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)

View File

@ -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() {

View File

@ -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

View File

@ -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) {