Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop sending the unused options parameter to various download-methods in the viewer #18551

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 8 additions & 18 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1109,22 +1109,17 @@ const PDFViewerApplication = {
);
},

async download(options = {}) {
async download() {
let data;
try {
data = await this.pdfDocument.getData();
} catch {
// When the PDF document isn't ready, simply download using the URL.
}
this.downloadManager.download(
data,
this._downloadUrl,
this._docFilename,
options
);
this.downloadManager.download(data, this._downloadUrl, this._docFilename);
},

async save(options = {}) {
async save() {
if (this._saveInProgress) {
return;
}
Expand All @@ -1133,16 +1128,11 @@ const PDFViewerApplication = {

try {
const data = await this.pdfDocument.saveDocument();
this.downloadManager.download(
data,
this._downloadUrl,
this._docFilename,
options
);
this.downloadManager.download(data, this._downloadUrl, this._docFilename);
} catch (reason) {
// When the PDF document isn't ready, fallback to a "regular" download.
console.error(`Error when saving the document: ${reason.message}`);
await this.download(options);
await this.download();
} finally {
await this.pdfScriptingManager.dispatchDidSave();
this._saveInProgress = false;
Expand All @@ -1159,7 +1149,7 @@ const PDFViewerApplication = {
}
},

async downloadOrSave(options = {}) {
async downloadOrSave() {
// In the Firefox case, this method MUST always trigger a download.
// When the user is closing a modified and unsaved document, we display a
// prompt asking for saving or not. In case they save, we must wait for
Expand All @@ -1169,8 +1159,8 @@ const PDFViewerApplication = {
const { classList } = this.appConfig.appContainer;
classList.add("wait");
await (this.pdfDocument?.annotationStorage.size > 0
? this.save(options)
: this.download(options));
? this.save()
: this.download());
classList.remove("wait");
},

Expand Down
2 changes: 1 addition & 1 deletion web/download_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class DownloadManager {
return false;
}

download(data, url, filename, _options) {
download(data, url, filename) {
let blobUrl;
if (data) {
blobUrl = URL.createObjectURL(
Expand Down
3 changes: 1 addition & 2 deletions web/firefoxcom.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class DownloadManager {
return false;
}

download(data, url, filename, options = {}) {
download(data, url, filename) {
const blobUrl = data
? URL.createObjectURL(new Blob([data], { type: "application/pdf" }))
: null;
Expand All @@ -142,7 +142,6 @@ class DownloadManager {
blobUrl,
originalUrl: url,
filename,
options,
});
}
}
Expand Down
3 changes: 1 addition & 2 deletions web/interfaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,8 @@ class IDownloadManager {
* @param {Uint8Array} data
* @param {string} url
* @param {string} filename
* @param {Object} [options]
*/
download(data, url, filename, options) {}
download(data, url, filename) {}
}

/**
Expand Down