summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-07-28 08:06:59 -0700
committerLukas Eipert <leipert@gitlab.com>2019-07-29 17:33:53 +0200
commit6d3b203dd8c0d18535b62eb65054342a5c9cd96c (patch)
tree2a304b28dddc39d0ca8a4934f4986bad64d85ead /app
parentdbe3b9848b884ca9705259110edf58e801c89e5e (diff)
downloadgitlab-ce-6d3b203dd8c0d18535b62eb65054342a5c9cd96c.tar.gz
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
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/pdf/index.vue8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/assets/javascripts/pdf/index.vue b/app/assets/javascripts/pdf/index.vue
index 6d39abd4a1f..a0142df0806 100644
--- a/app/assets/javascripts/pdf/index.vue
+++ b/app/assets/javascripts/pdf/index.vue
@@ -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);
},