Skip to content

Commit

Permalink
Merge branch 'omp-jb51205' into 'master'
Browse files Browse the repository at this point in the history
[embedlite-components] Add a flag to track saving webpage as PDF. Contributes to JB#51205

See merge request mer-core/embedlite-components!85
  • Loading branch information
rainemak committed Oct 22, 2020
2 parents 2698c4e + 19d35cf commit d8d0224
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions jscomps/EmbedliteDownloadManager.js
Expand Up @@ -49,6 +49,7 @@ let DownloadView = {
JSON.stringify({
msg: "dl-start",
id: this.counter,
saveAsPdf: download.saveAsPdf || false,
displayName: download.target.path.split('/').slice(-1)[0],
sourceUrl: download.source.url,
targetPath: download.target.path,
Expand All @@ -61,6 +62,7 @@ let DownloadView = {
JSON.stringify({
msg: "dl-progress",
id: this.prevState[download].id,
saveAsPdf: download.saveAsPdf || false,
percent: download.progress
}));
}
Expand All @@ -70,6 +72,7 @@ let DownloadView = {
JSON.stringify({
msg: "dl-done",
id: this.prevState[download].id,
saveAsPdf: download.saveAsPdf || false,
targetPath: download.target.path
}));
}
Expand All @@ -79,15 +82,17 @@ let DownloadView = {
Services.obs.notifyObservers(null, "embed:download",
JSON.stringify({
msg: "dl-fail",
id: this.prevState[download].id
id: this.prevState[download].id,
saveAsPdf: download.saveAsPdf || false
}));
}

if (download.canceled) {
Services.obs.notifyObservers(null, "embed:download",
JSON.stringify({
msg: "dl-cancel",
id: this.prevState[download].id
id: this.prevState[download].id,
saveAsPdf: download.saveAsPdf || false
}));
}
},
Expand All @@ -98,6 +103,7 @@ let DownloadView = {
JSON.stringify({
msg: "dl-progress",
id: this.prevState[download].id,
saveAsPdf: download.saveAsPdf || false,
percent: download.progress
}));
}
Expand All @@ -108,6 +114,7 @@ let DownloadView = {
JSON.stringify({
msg: "dl-done",
id: this.prevState[download].id,
saveAsPdf: download.saveAsPdf || false,
targetPath: download.target.path
}));
}
Expand All @@ -118,7 +125,8 @@ let DownloadView = {
Services.obs.notifyObservers(null, "embed:download",
JSON.stringify({
msg: "dl-fail",
id: this.prevState[download].id
id: this.prevState[download].id,
saveAsPdf: download.saveAsPdf || false
}));
}
this.prevState[download].error = download.error;
Expand All @@ -127,7 +135,8 @@ let DownloadView = {
Services.obs.notifyObservers(null, "embed:download",
JSON.stringify({
msg: "dl-cancel",
id: this.prevState[download].id
id: this.prevState[download].id,
saveAsPdf: download.saveAsPdf || false
}));
}
this.prevState[download].canceled = download.canceled;
Expand All @@ -137,6 +146,7 @@ let DownloadView = {
JSON.stringify({
msg: "dl-start",
id: this.prevState[download].id,
saveAsPdf: download.saveAsPdf || false,
displayName: download.target.path.split('/').slice(-1)[0],
sourceUrl: download.source.url,
targetPath: download.target.path,
Expand Down Expand Up @@ -237,6 +247,7 @@ EmbedliteDownloadManager.prototype = {
saver: "pdf",
contentType: "application/pdf"
});
download["saveAsPdf"] = true;
download.start();
list.add(download);
}).then(null, Cu.reportError);
Expand Down

0 comments on commit d8d0224

Please sign in to comment.