diff --git a/client/components/cards/LazyBookCard.vue b/client/components/cards/LazyBookCard.vue index 715d47a1..7e9a400f 100644 --- a/client/components/cards/LazyBookCard.vue +++ b/client/components/cards/LazyBookCard.vue @@ -260,7 +260,7 @@ export default { return this.bookCoverAspectRatio === 1 }, sizeMultiplier() { - var baseSize = this.squareAspectRatio ? 192 : 120 + const baseSize = this.squareAspectRatio ? 192 : 120 return this.width / baseSize }, title() { @@ -538,11 +538,11 @@ export default { return this.author }, isAlternativeBookshelfView() { - var constants = this.$constants || this.$nuxt.$constants + const constants = this.$constants || this.$nuxt.$constants return this.bookshelfView === constants.BookshelfView.DETAIL }, isAuthorBookshelfView() { - var constants = this.$constants || this.$nuxt.$constants + const constants = this.$constants || this.$nuxt.$constants return this.bookshelfView === constants.BookshelfView.AUTHOR }, titleDisplayBottomOffset() { @@ -552,7 +552,7 @@ export default { }, rssFeed() { if (this.booksInSeries) return null - return this.store.getters['feeds/getFeedForItem'](this.libraryItemId) + return this._libraryItem.rssFeed || null } }, methods: { diff --git a/client/layouts/default.vue b/client/layouts/default.vue index 05729252..727f0687 100644 --- a/client/layouts/default.vue +++ b/client/layouts/default.vue @@ -330,10 +330,10 @@ export default { this.$store.commit('libraries/removeUserPlaylist', playlist) }, rssFeedOpen(data) { - this.$store.commit('feeds/addFeed', data) + console.log('RSS Feed Open', data) }, rssFeedClosed(data) { - this.$store.commit('feeds/removeFeed', data) + console.log('RSS Feed Closed', data) }, backupApplied() { // Force refresh diff --git a/client/pages/login.vue b/client/pages/login.vue index b1bcf75b..a94045ae 100644 --- a/client/pages/login.vue +++ b/client/pages/login.vue @@ -127,7 +127,6 @@ export default { setUser({ user, userDefaultLibraryId, serverSettings, Source, feeds }) { this.$store.commit('setServerSettings', serverSettings) this.$store.commit('setSource', Source) - this.$store.commit('feeds/setFeeds', feeds) this.$setServerLanguageCode(serverSettings.language) if (serverSettings.chromecastEnabled) { diff --git a/client/store/feeds.js b/client/store/feeds.js deleted file mode 100644 index 281f5dd4..00000000 --- a/client/store/feeds.js +++ /dev/null @@ -1,28 +0,0 @@ - -export const state = () => ({ - feeds: [] -}) - -export const getters = { - getFeedForItem: state => id => { - return state.feeds.find(feed => feed.id === id) - } -} - -export const actions = { - -} - -export const mutations = { - addFeed(state, feed) { - var index = state.feeds.findIndex(f => f.id === feed.id) - if (index >= 0) state.feeds.splice(index, 1, feed) - else state.feeds.push(feed) - }, - removeFeed(state, feed) { - state.feeds = state.feeds.filter(f => f.id !== feed.id) - }, - setFeeds(state, feeds) { - state.feeds = feeds || [] - } -} \ No newline at end of file diff --git a/server/Auth.js b/server/Auth.js index d27d3844..2bca48d2 100644 --- a/server/Auth.js +++ b/server/Auth.js @@ -115,17 +115,16 @@ class Auth { }) } - getUserLoginResponsePayload(user, feeds) { + getUserLoginResponsePayload(user) { return { user: user.toJSONForBrowser(), userDefaultLibraryId: user.getDefaultLibraryId(this.db.libraries), serverSettings: this.db.serverSettings.toJSONForBrowser(), - feeds, Source: global.Source } } - async login(req, res, feeds) { + async login(req, res) { const ipAddress = requestIp.getClientIp(req) var username = (req.body.username || '').toLowerCase() var password = req.body.password || '' @@ -146,14 +145,14 @@ class Auth { if (password) { return res.status(401).send('Invalid root password (hint: there is none)') } else { - return res.json(this.getUserLoginResponsePayload(user, feeds)) + return res.json(this.getUserLoginResponsePayload(user)) } } // Check password match var compare = await bcrypt.compare(password, user.pash) if (compare) { - res.json(this.getUserLoginResponsePayload(user, feeds)) + res.json(this.getUserLoginResponsePayload(user)) } else { Logger.warn(`[Auth] Failed login attempt ${req.rateLimit.current} of ${req.rateLimit.limit} from ${ipAddress}`) if (req.rateLimit.remaining <= 2) { diff --git a/server/Server.js b/server/Server.js index d23106ee..4a6e2e45 100644 --- a/server/Server.js +++ b/server/Server.js @@ -212,7 +212,7 @@ class Server { ] dyanimicRoutes.forEach((route) => router.get(route, (req, res) => res.sendFile(Path.join(distPath, 'index.html')))) - router.post('/login', this.getLoginRateLimiter(), (req, res) => this.auth.login(req, res, this.rssFeedManager.feedsArray)) + router.post('/login', this.getLoginRateLimiter(), (req, res) => this.auth.login(req, res)) router.post('/logout', this.authMiddleware.bind(this), this.logout.bind(this)) router.post('/init', (req, res) => { if (this.db.hasRootUser) { diff --git a/server/controllers/LibraryController.js b/server/controllers/LibraryController.js index f987e060..73f2cd84 100644 --- a/server/controllers/LibraryController.js +++ b/server/controllers/LibraryController.js @@ -170,8 +170,11 @@ class LibraryController { // api/libraries/:id/items // TODO: Optimize this method, items are iterated through several times but can be combined getLibraryItems(req, res) { - var libraryItems = req.libraryItems - var payload = { + let libraryItems = req.libraryItems + + const include = (req.query.include || '').split(',').map(v => v.trim().toLowerCase()).filter(v => !!v) + + const payload = { results: [], total: libraryItems.length, limit: req.query.limit && !isNaN(req.query.limit) ? Number(req.query.limit) : 0, @@ -181,7 +184,8 @@ class LibraryController { filterBy: req.query.filter, mediaType: req.library.mediaType, minified: req.query.minified === '1', - collapseseries: req.query.collapseseries === '1' + collapseseries: req.query.collapseseries === '1', + include: include.join(',') } const mediaIsBook = payload.mediaType === 'book' @@ -219,7 +223,7 @@ class LibraryController { } // Step 3 - Sort the retrieved library items. - var sortArray = [] + const sortArray = [] // When on the series page, sort by sequence only if (payload.sortBy === 'book.volumeNumber') payload.sortBy = null // TODO: Remove temp fix after mobile release 0.9.60 @@ -294,13 +298,13 @@ class LibraryController { // Step 3.5: Limit items if (payload.limit) { - var startIndex = payload.page * payload.limit + const startIndex = payload.page * payload.limit libraryItems = libraryItems.slice(startIndex, startIndex + payload.limit) } // Step 4 - Transform the items to pass to the client side payload.results = libraryItems.map(li => { - let json = payload.minified ? li.toJSONMinified() : li.toJSON() + const json = payload.minified ? li.toJSONMinified() : li.toJSON() if (li.collapsedSeries) { json.collapsedSeries = { @@ -333,9 +337,16 @@ class LibraryController { .map(r => r.start == r.end ? r.start : `${r.start}-${r.end}`) .join(', ') } - } else if (filterSeries) { - // If filtering by series, make sure to include the series metadata - json.media.metadata.series = li.media.metadata.getSeries(filterSeries) + } else { + // add rssFeed object if "include=rssfeed" was put in query string (only for non-collapsed series) + if (include.includes('rssfeed')) { + json.rssFeed = this.rssFeedManager.findFeedForEntityId(json.id) + } + + if (filterSeries) { + // If filtering by series, make sure to include the series metadata + json.media.metadata.series = li.media.metadata.getSeries(filterSeries) + } } return json diff --git a/server/controllers/MiscController.js b/server/controllers/MiscController.js index dddc82a8..69e5be22 100644 --- a/server/controllers/MiscController.js +++ b/server/controllers/MiscController.js @@ -122,7 +122,7 @@ class MiscController { Logger.error('Invalid user in authorize') return res.sendStatus(401) } - const userResponse = this.auth.getUserLoginResponsePayload(req.user, this.rssFeedManager.feedsArray) + const userResponse = this.auth.getUserLoginResponsePayload(req.user) res.json(userResponse) } diff --git a/server/utils/libraryHelpers.js b/server/utils/libraryHelpers.js index caa10439..714a702e 100644 --- a/server/utils/libraryHelpers.js +++ b/server/utils/libraryHelpers.js @@ -291,11 +291,11 @@ module.exports = { collapseBookSeries(libraryItems, series, filterSeries) { // Get series from the library items. If this list is being collapsed after filtering for a series, // don't collapse that series, only books that are in other series. - var seriesObjects = this + const seriesObjects = this .getSeriesFromBooks(libraryItems, series, filterSeries, null, null, true) .filter(s => s.id != filterSeries) - var filteredLibraryItems = [] + const filteredLibraryItems = [] libraryItems.forEach((li) => { if (li.mediaType != 'book') return @@ -307,12 +307,12 @@ module.exports = { filteredLibraryItems.push(Object.assign( Object.create(Object.getPrototypeOf(li)), li, { collapsedSeries: series })) - }); + }) // Only included books not contained in series if (!seriesObjects.some(s => s.books.some(b => b.id == li.id))) filteredLibraryItems.push(li) - }); + }) return filteredLibraryItems },