Fix pdf.js rendering pages in the wrong order
There was an implicit assumption that the pages returned from the Promise of `pdf.getPage(num)` would return in order, but no such guarantee exists. To handle this, we explicitly set which array index based on the page number and then trigger a Vue update via `splice`. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/64467
This commit is contained in:
parent
dbe3b9848b
commit
6d3b203dd8
|
@ -40,6 +40,8 @@ export default {
|
|||
.then(() => this.$emit('pdflabload'))
|
||||
.catch(error => this.$emit('pdflaberror', error))
|
||||
.then(() => {
|
||||
// Trigger a Vue update: https://vuejs.org/v2/guide/list.html#Caveats
|
||||
this.pages.splice(this.pages.length);
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
|
@ -47,7 +49,11 @@ export default {
|
|||
const pagePromises = [];
|
||||
this.loading = true;
|
||||
for (let num = 1; num <= pdf.numPages; num += 1) {
|
||||
pagePromises.push(pdf.getPage(num).then(p => this.pages.push(p)));
|
||||
pagePromises.push(
|
||||
pdf.getPage(num).then(p => {
|
||||
this.pages[p.pageIndex] = p;
|
||||
}),
|
||||
);
|
||||
}
|
||||
return Promise.all(pagePromises);
|
||||
},
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Fix pdf.js rendering pages in the wrong order
|
||||
merge_request: 31222
|
||||
author:
|
||||
type: fixed
|
Loading…
Reference in New Issue