Fix:Handle undefined page/limit in paginated library queries #3499

This commit is contained in:
advplyr 2024-10-11 17:15:16 -05:00
parent 33eae1e03a
commit 076f71d490

View File

@ -492,8 +492,8 @@ class LibraryController {
const payload = { const payload = {
results: [], results: [],
total: undefined, total: undefined,
limit: req.query.limit, limit: req.query.limit || 0,
page: req.query.page, page: req.query.page || 0,
sortBy: req.query.sort, sortBy: req.query.sort,
sortDesc: req.query.desc === '1', sortDesc: req.query.desc === '1',
filterBy: req.query.filter, filterBy: req.query.filter,
@ -594,8 +594,8 @@ class LibraryController {
const payload = { const payload = {
results: [], results: [],
total: 0, total: 0,
limit: req.query.limit, limit: req.query.limit || 0,
page: req.query.page, page: req.query.page || 0,
sortBy: req.query.sort, sortBy: req.query.sort,
sortDesc: req.query.desc === '1', sortDesc: req.query.desc === '1',
filterBy: req.query.filter, filterBy: req.query.filter,
@ -666,8 +666,8 @@ class LibraryController {
const payload = { const payload = {
results: [], results: [],
total: 0, total: 0,
limit: req.query.limit, limit: req.query.limit || 0,
page: req.query.page, page: req.query.page || 0,
sortBy: req.query.sort, sortBy: req.query.sort,
sortDesc: req.query.desc === '1', sortDesc: req.query.desc === '1',
filterBy: req.query.filter, filterBy: req.query.filter,
@ -702,8 +702,8 @@ class LibraryController {
const payload = { const payload = {
results: [], results: [],
total: playlistsForUser.length, total: playlistsForUser.length,
limit: req.query.limit, limit: req.query.limit || 0,
page: req.query.page page: req.query.page || 0
} }
if (payload.limit) { if (payload.limit) {
@ -1139,8 +1139,8 @@ class LibraryController {
const payload = { const payload = {
episodes: [], episodes: [],
limit: req.query.limit, limit: req.query.limit || 0,
page: req.query.page page: req.query.page || 0
} }
const offset = payload.page * payload.limit const offset = payload.page * payload.limit