mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
fix(watchlist): correctly load more than 20 watchlist items (#3351)
* fix(discover): correctly load additional watchlist items pages * chore(discover): remove unused params types
This commit is contained in:

committed by
GitHub

parent
eb5502a16f
commit
af880a6c83
@@ -800,12 +800,12 @@ discoverRoutes.get<{ language: string }, GenreSliderItem[]>(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
discoverRoutes.get<{ page?: number }, WatchlistResponse>(
|
discoverRoutes.get<Record<string, unknown>, WatchlistResponse>(
|
||||||
'/watchlist',
|
'/watchlist',
|
||||||
async (req, res) => {
|
async (req, res) => {
|
||||||
const userRepository = getRepository(User);
|
const userRepository = getRepository(User);
|
||||||
const itemsPerPage = 20;
|
const itemsPerPage = 20;
|
||||||
const page = req.params.page ?? 1;
|
const page = Number(req.query.page) ?? 1;
|
||||||
const offset = (page - 1) * itemsPerPage;
|
const offset = (page - 1) * itemsPerPage;
|
||||||
|
|
||||||
const activeUser = await userRepository.findOne({
|
const activeUser = await userRepository.findOne({
|
||||||
@@ -829,8 +829,8 @@ discoverRoutes.get<{ page?: number }, WatchlistResponse>(
|
|||||||
|
|
||||||
return res.json({
|
return res.json({
|
||||||
page,
|
page,
|
||||||
totalPages: Math.ceil(watchlist.size / itemsPerPage),
|
totalPages: Math.ceil(watchlist.totalSize / itemsPerPage),
|
||||||
totalResults: watchlist.size,
|
totalResults: watchlist.totalSize,
|
||||||
results: watchlist.items.map((item) => ({
|
results: watchlist.items.map((item) => ({
|
||||||
ratingKey: item.ratingKey,
|
ratingKey: item.ratingKey,
|
||||||
title: item.title,
|
title: item.title,
|
||||||
|
@@ -607,7 +607,7 @@ router.get<{ id: string }, UserWatchDataResponse>(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
router.get<{ id: string; page?: number }, WatchlistResponse>(
|
router.get<{ id: string }, WatchlistResponse>(
|
||||||
'/:id/watchlist',
|
'/:id/watchlist',
|
||||||
async (req, res, next) => {
|
async (req, res, next) => {
|
||||||
if (
|
if (
|
||||||
@@ -627,7 +627,7 @@ router.get<{ id: string; page?: number }, WatchlistResponse>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const itemsPerPage = 20;
|
const itemsPerPage = 20;
|
||||||
const page = req.params.page ?? 1;
|
const page = Number(req.query.page) ?? 1;
|
||||||
const offset = (page - 1) * itemsPerPage;
|
const offset = (page - 1) * itemsPerPage;
|
||||||
|
|
||||||
const user = await getRepository(User).findOneOrFail({
|
const user = await getRepository(User).findOneOrFail({
|
||||||
@@ -651,8 +651,8 @@ router.get<{ id: string; page?: number }, WatchlistResponse>(
|
|||||||
|
|
||||||
return res.json({
|
return res.json({
|
||||||
page,
|
page,
|
||||||
totalPages: Math.ceil(watchlist.size / itemsPerPage),
|
totalPages: Math.ceil(watchlist.totalSize / itemsPerPage),
|
||||||
totalResults: watchlist.size,
|
totalResults: watchlist.totalSize,
|
||||||
results: watchlist.items.map((item) => ({
|
results: watchlist.items.map((item) => ({
|
||||||
ratingKey: item.ratingKey,
|
ratingKey: item.ratingKey,
|
||||||
title: item.title,
|
title: item.title,
|
||||||
|
Reference in New Issue
Block a user