Skip to content

Commit

Permalink
Update home page shelves to handle share open/closed sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
advplyr committed Jul 7, 2024
1 parent af92ae4 commit 0918391
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions client/components/app/BookShelfCategorized.vue
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,36 @@ export default {
}
})
},
shareOpen(mediaItemShare) {
this.shelves.forEach((shelf) => {
if (shelf.type == 'book') {
shelf.entities = shelf.entities.map((ent) => {
if (ent.media.id === mediaItemShare.mediaItemId) {
return {
...ent,
mediaItemShare
}
}
return ent
})
}
})
},
shareClosed(mediaItemShare) {
this.shelves.forEach((shelf) => {
if (shelf.type == 'book') {
shelf.entities = shelf.entities.map((ent) => {
if (ent.media.id === mediaItemShare.mediaItemId) {
return {
...ent,
mediaItemShare: null
}
}
return ent
})
}
})
},
initListeners() {
if (this.$root.socket) {
this.$root.socket.on('user_updated', this.userUpdated)
Expand All @@ -419,6 +449,8 @@ export default {
this.$root.socket.on('items_updated', this.libraryItemsUpdated)
this.$root.socket.on('items_added', this.libraryItemsAdded)
this.$root.socket.on('episode_added', this.episodeAdded)
this.$root.socket.on('share_open', this.shareOpen)
this.$root.socket.on('share_closed', this.shareClosed)
} else {
console.error('Error socket not initialized')
}
Expand All @@ -434,6 +466,8 @@ export default {
this.$root.socket.off('items_updated', this.libraryItemsUpdated)
this.$root.socket.off('items_added', this.libraryItemsAdded)
this.$root.socket.off('episode_added', this.episodeAdded)
this.$root.socket.off('share_open', this.shareOpen)
this.$root.socket.off('share_closed', this.shareClosed)
} else {
console.error('Error socket not initialized')
}
Expand Down

0 comments on commit 0918391

Please sign in to comment.