Skip to content

Commit fb6c807

Browse files
committed
Reduce unnecessary duplication in PDFRenderingQueue.getHighestPriority
1 parent 284d259 commit fb6c807

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

web/pdf_rendering_queue.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,15 @@ class PDFRenderingQueue {
126126
}
127127
}
128128

129-
// All the visible views have rendered; try to render next/previous pages.
130-
if (scrolledDown) {
131-
const nextPageIndex = visible.last.id;
132-
// IDs start at 1, so no need to add 1.
133-
if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
134-
return views[nextPageIndex];
135-
}
136-
} else {
137-
const previousPageIndex = visible.first.id - 2;
138-
if (
139-
views[previousPageIndex] &&
140-
!this.isViewFinished(views[previousPageIndex])
141-
) {
142-
return views[previousPageIndex];
143-
}
129+
// All the visible views have rendered; try to render next/previous page.
130+
// (IDs start at 1, so no need to add 1 when `scrolledDown === true`.)
131+
const preRenderIndex = scrolledDown
132+
? visible.last.id
133+
: visible.first.id - 2;
134+
const preRenderView = views[preRenderIndex];
135+
136+
if (preRenderView && !this.isViewFinished(preRenderView)) {
137+
return preRenderView;
144138
}
145139
// Everything that needs to be rendered has been.
146140
return null;

0 commit comments

Comments
 (0)