Skip to content

Commit

Permalink
Update:Get personalized home page shelves and get library items endpo…
Browse files Browse the repository at this point in the history
…int optional includes for media item shares, show public icon on shared book items
  • Loading branch information
advplyr committed Jul 1, 2024
1 parent 134c258 commit d5e00c8
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 79 deletions.
2 changes: 1 addition & 1 deletion client/components/app/BookShelfCategorized.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export default {
},
async fetchCategories() {
const categories = await this.$axios
.$get(`/api/libraries/${this.currentLibraryId}/personalized?include=rssfeed,numEpisodesIncomplete`)
.$get(`/api/libraries/${this.currentLibraryId}/personalized?include=rssfeed,numEpisodesIncomplete,share`)
.then((data) => {
return data
})
Expand Down
2 changes: 1 addition & 1 deletion client/components/app/LazyBookshelf.vue
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export default {
let entityPath = this.entityName === 'series-books' ? 'items' : this.entityName
const sfQueryString = this.currentSFQueryString ? this.currentSFQueryString + '&' : ''
const fullQueryString = `?${sfQueryString}limit=${this.booksPerFetch}&page=${page}&minified=1&include=rssfeed,numEpisodesIncomplete`
const fullQueryString = `?${sfQueryString}limit=${this.booksPerFetch}&page=${page}&minified=1&include=rssfeed,numEpisodesIncomplete,share`
const payload = await this.$axios.$get(`/api/libraries/${this.currentLibraryId}/${entityPath}${fullQueryString}`).catch((error) => {
console.error('failed to fetch items', error)
Expand Down
8 changes: 8 additions & 0 deletions client/components/cards/LazyBookCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,14 @@
</div>
</ui-tooltip>

<!-- rss feed icon -->
<div cy-id="rssFeed" v-if="rssFeed && !isSelectionMode && !isHovering" class="absolute text-success top-0 left-0 z-10" :style="{ padding: 0.375 + 'em' }">
<span class="material-icons" :style="{ fontSize: 1.5 + 'em' }">rss_feed</span>
</div>
<!-- media item shared icon -->
<div cy-id="mediaItemShare" v-if="mediaItemShare && !isSelectionMode && !isHovering" class="absolute text-success left-0 z-10" :style="{ padding: 0.375 + 'em', top: rssFeed ? '2em' : '0px' }">
<span class="material-icons" :style="{ fontSize: 1.5 + 'em' }">public</span>
</div>

<!-- Series sequence -->
<div cy-id="seriesSequence" v-if="seriesSequence && !isHovering && !isSelectionMode" class="absolute rounded-lg bg-black bg-opacity-90 box-shadow-md z-10" :style="{ top: 0.375 + 'em', right: 0.375 + 'em', padding: `${0.1}em ${0.25}em` }">
Expand Down Expand Up @@ -627,6 +632,9 @@ export default {
rssFeed() {
if (this.booksInSeries) return null
return this._libraryItem.rssFeed || null
},
mediaItemShare() {
return this._libraryItem.mediaItemShare || null
}
},
methods: {
Expand Down
2 changes: 1 addition & 1 deletion server/controllers/LibraryItemController.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class LibraryItemController {
/**
* GET: /api/items/:id
* Optional query params:
* ?include=progress,rssfeed,downloads
* ?include=progress,rssfeed,downloads,share
* ?expanded=1
*
* @param {import('express').Request} req
Expand Down
8 changes: 7 additions & 1 deletion server/models/LibraryItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const LibraryFile = require('../objects/files/LibraryFile')
const Book = require('./Book')
const Podcast = require('./Podcast')

const ShareManager = require('../managers/ShareManager')

/**
* @typedef LibraryFileObject
* @property {string} ino
Expand Down Expand Up @@ -537,7 +539,7 @@ class LibraryItem extends Model {
* @param {oldLibrary} library
* @param {oldUser} user
* @param {object} options
* @returns {object} { libraryItems:oldLibraryItem[], count:number }
* @returns {{ libraryItems:oldLibraryItem[], count:number }}
*/
static async getByFilterAndSort(library, user, options) {
let start = Date.now()
Expand Down Expand Up @@ -565,6 +567,10 @@ class LibraryItem extends Model {
if (li.numEpisodesIncomplete) {
oldLibraryItem.numEpisodesIncomplete = li.numEpisodesIncomplete
}
if (li.mediaType === 'book' && options.include?.includes?.('share')) {
console.log('Lookup share for media item id', li.mediaId)
oldLibraryItem.mediaItemShare = ShareManager.findByMediaItemId(li.mediaId)
}

return oldLibraryItem
}),
Expand Down
Loading

0 comments on commit d5e00c8

Please sign in to comment.