Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronleopold committed Nov 9, 2024
2 parents 4055495 + ffc7364 commit c7e0d30
Show file tree
Hide file tree
Showing 33 changed files with 10,550 additions and 457 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion core/src/filesystem/scanner/library_scan_job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,16 @@ impl JobExt for LibraryScanJob {
// If the library is not collection-priority, each subdirectory is its own series.
// Therefore, we only scan one level deep when walking a series whose library is not
// collection-priority to avoid scanning duplicates which are part of other series
let max_depth = self
let mut max_depth = self
.config
.as_ref()
.and_then(|o| (!o.is_collection_based()).then_some(1));
if path_buf == PathBuf::from(&self.path) {
// The exception is when the series "is" the libray (i.e. the root of the library contains
// books). This is kind of an anti-pattern wrt collection-priority, but it needs to be handled
// in order to avoid the scanner re-scanning the entire library...
max_depth = Some(1);
}

let Some(Ok(ignore_rules)) =
self.config.as_ref().map(|o| o.ignore_rules.build())
Expand Down
9 changes: 8 additions & 1 deletion core/src/filesystem/scanner/series_scan_job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ impl JobExt for SeriesScanJob {
ctx: &WorkerCtx,
) -> Result<WorkingState<Self::Output, Self::Task>, JobError> {
let mut output = Self::Output::default();
let path_buf = PathBuf::from(self.path.clone());
let library = ctx
.db
.library()
Expand All @@ -123,7 +124,13 @@ impl JobExt for SeriesScanJob {
// If the library is not collection-priority, each subdirectory is its own series.
// Therefore, we only scan one level deep when walking a series whose library is not
// collection-priority to avoid scanning duplicates which are part of other series
let max_depth = (!library_config.is_collection_based()).then_some(1);
let mut max_depth = (!library_config.is_collection_based()).then_some(1);
if path_buf == PathBuf::from(&library.path) {
// The exception is when the series "is" the libray (i.e. the root of the library contains
// books). This is kind of an anti-pattern wrt collection-priority, but it needs to be handled
// in order to avoid the scanner re-scanning the entire library...
max_depth = Some(1);
}

self.config = Some(library_config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const PageSet = forwardRef<HTMLDivElement, Props>(
const renderSet = () => {
const shouldDisplayDoubleSpread =
displayedPages.length > 1 &&
currentPage != 1 &&
dimensionSet.every((dimensions) => !dimensions || dimensions.isPortrait)

if (shouldDisplayDoubleSpread) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,17 @@ function PagedReader({ currentPage, media, onPageChange, getPageUrl }: PagedRead
const pageSetRef = useRef<HTMLDivElement | null>(null)

// TODO: this needs to be aware of overflow / if the page is too small to render double spread
const displayedPages = useMemo(
() =>
doubleSpread ? [currentPage, currentPage + 1].filter((p) => p <= media.pages) : [currentPage],
[currentPage, doubleSpread, media.pages],
)
const displayedPages = useMemo(() => {
if (readingDirection === 'ltr') {
return doubleSpread
? [currentPage, currentPage + 1].filter((p) => p <= media.pages)
: [currentPage]
} else {
return doubleSpread
? [currentPage + 1, currentPage].filter((p) => p <= media.pages)
: [currentPage]
}
}, [currentPage, doubleSpread, media.pages])

/**
* If the image parts are collective >= 80% of the screen width, we want to fix the side navigation
Expand Down Expand Up @@ -91,7 +97,8 @@ function PagedReader({ currentPage, media, onPageChange, getPageUrl }: PagedRead
*/
const handleLeftwardPageChange = useCallback(() => {
const direction = readingDirection === 'ltr' ? -1 : 1
if (doubleSpread) {
const skip = readingDirection === 'ltr' ? 2 : 1
if (doubleSpread && currentPage > skip) {
const adjustedForBounds = currentPage + direction * 2 < 1 ? 1 : currentPage + direction * 2
doChangePage(adjustedForBounds)
} else {
Expand All @@ -104,7 +111,8 @@ function PagedReader({ currentPage, media, onPageChange, getPageUrl }: PagedRead
*/
const handleRightwardPageChange = useCallback(() => {
const direction = readingDirection === 'ltr' ? 1 : -1
if (doubleSpread) {
const skip = readingDirection === 'ltr' ? 1 : 2
if (doubleSpread && currentPage > skip) {
const adjustedForBounds =
currentPage + direction * 2 > media.pages ? media.pages : currentPage + direction * 2
doChangePage(adjustedForBounds)
Expand Down
Loading

0 comments on commit c7e0d30

Please sign in to comment.