mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-07-29 23:25:47 +02:00
Update:Bookmarks modal is not closed on updating/deleting and does not show a toast #882
This commit is contained in:
parent
e9251db647
commit
087e8553c4
2 changed files with 21 additions and 7 deletions
|
@ -105,30 +105,28 @@ export default {
|
||||||
this.$nativeHttp
|
this.$nativeHttp
|
||||||
.delete(`/api/me/item/${this.libraryItemId}/bookmark/${bm.time}`)
|
.delete(`/api/me/item/${this.libraryItemId}/bookmark/${bm.time}`)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.$toast.success('Bookmark removed')
|
this.$store.commit('user/deleteBookmark', { libraryItemId: this.libraryItemId, time: bm.time })
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.$toast.error(`Failed to remove bookmark`)
|
this.$toast.error(`Failed to remove bookmark`)
|
||||||
console.error(error)
|
console.error(error)
|
||||||
})
|
})
|
||||||
this.show = false
|
|
||||||
},
|
},
|
||||||
async clickBookmark(bm) {
|
async clickBookmark(bm) {
|
||||||
await this.$hapticsImpact()
|
await this.$hapticsImpact()
|
||||||
this.$emit('select', bm)
|
this.$emit('select', bm)
|
||||||
},
|
},
|
||||||
submitUpdateBookmark(updatedBookmark) {
|
submitUpdateBookmark(updatedBookmark) {
|
||||||
var bookmark = { ...updatedBookmark }
|
|
||||||
this.$nativeHttp
|
this.$nativeHttp
|
||||||
.patch(`/api/me/item/${this.libraryItemId}/bookmark`, bookmark)
|
.patch(`/api/me/item/${this.libraryItemId}/bookmark`, updatedBookmark)
|
||||||
.then(() => {
|
.then((bookmark) => {
|
||||||
this.$toast.success('Bookmark updated')
|
this.$store.commit('user/updateBookmark', bookmark)
|
||||||
|
this.showBookmarkTitleInput = false
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.$toast.error(`Failed to update bookmark`)
|
this.$toast.error(`Failed to update bookmark`)
|
||||||
console.error(error)
|
console.error(error)
|
||||||
})
|
})
|
||||||
this.show = false
|
|
||||||
},
|
},
|
||||||
submitCreateBookmark() {
|
submitCreateBookmark() {
|
||||||
if (!this.newBookmarkTitle) {
|
if (!this.newBookmarkTitle) {
|
||||||
|
|
|
@ -145,5 +145,21 @@ export const mutations = {
|
||||||
setSettings(state, settings) {
|
setSettings(state, settings) {
|
||||||
if (!settings) return
|
if (!settings) return
|
||||||
state.settings = settings
|
state.settings = settings
|
||||||
|
},
|
||||||
|
updateBookmark(state, bookmark) {
|
||||||
|
if (!state.user?.bookmarks) return
|
||||||
|
state.user.bookmarks = state.user.bookmarks.map((bm) => {
|
||||||
|
if (bm.libraryItemId === bookmark.libraryItemId && bm.time === bookmark.time) {
|
||||||
|
return bookmark
|
||||||
|
}
|
||||||
|
return bm
|
||||||
|
})
|
||||||
|
},
|
||||||
|
deleteBookmark(state, { libraryItemId, time }) {
|
||||||
|
if (!state.user?.bookmarks) return
|
||||||
|
state.user.bookmarks = state.user.bookmarks.filter(bm => {
|
||||||
|
if (bm.libraryItemId === libraryItemId && bm.time === time) return false
|
||||||
|
return true
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue