cmp used for skip calculating
@@ -8,6 +8,7 @@ use boolinator::Boolinator;
use derivative::Derivative;
use itertools::Itertools;
use serde::{Deserialize, Serialize};
+use std::cmp;
use std::iter;
use std::marker::PhantomData;
use strum::IntoEnumIterator;
@@ -275,11 +276,7 @@ fn catalog_update<F: LibraryFilter>(
Sort::TimesWatched => b.state.times_watched.cmp(&a.state.times_watched),
Sort::Name => a.name.to_lowercase().cmp(&b.name.to_lowercase()),
})
- .skip(if selected.request.page > 0 {
- (selected.request.page - 1) * CATALOG_PAGE_SIZE
- } else {
- 0
- })
+ .skip(cmp::max(0, selected.request.page as isize - 1) as usize * CATALOG_PAGE_SIZE)
.take(CATALOG_PAGE_SIZE)
.cloned()
.collect(),
