Skip to content

Commit

Permalink
Merge pull request mozilla#14624 from Snuffleupagus/viewer-fallback-c…
Browse files Browse the repository at this point in the history
…leanup

Simplify the `fallback`-logic in the default viewer
  • Loading branch information
timvandermeij authored Mar 2, 2022
2 parents 038c832 + 6d2863f commit 234aa9a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
25 changes: 1 addition & 24 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,6 @@ class DefaultExternalServices {

static initPassiveLoading(callbacks) {}

static async fallback(data) {}

static reportTelemetry(data) {}

static createDownloadManager(options) {
Expand Down Expand Up @@ -192,7 +190,6 @@ class DefaultExternalServices {
const PDFViewerApplication = {
initialBookmark: document.location.hash.substring(1),
_initializedCapability: createPromiseCapability(),
_fellback: false,
appConfig: null,
pdfDocument: null,
pdfLoadingTask: null,
Expand Down Expand Up @@ -825,7 +822,6 @@ const PDFViewerApplication = {
this.pdfDocumentProperties.setDocument(null);
}
this.pdfLinkService.externalLinkEnabled = true;
this._fellback = false;
this.store = null;
this.isInitialViewSet = false;
this.downloadComplete = false;
Expand Down Expand Up @@ -924,7 +920,7 @@ const PDFViewerApplication = {
this.progress(loaded / total);
};

// Listen for unsupported features to trigger the fallback UI.
// Listen for unsupported features to report telemetry.
loadingTask.onUnsupportedFeature = this.fallback.bind(this);

return loadingTask.promise.then(
Expand Down Expand Up @@ -1019,25 +1015,6 @@ const PDFViewerApplication = {
type: "unsupportedFeature",
featureId,
});

// Only trigger the fallback once so we don't spam the user with messages
// for one PDF.
if (this._fellback) {
return;
}
this._fellback = true;

this.externalServices
.fallback({
featureId,
url: this.baseUrl,
})
.then(download => {
if (!download) {
return;
}
this.download({ sourceEventType: "download" });
});
},

/**
Expand Down
4 changes: 0 additions & 4 deletions web/firefoxcom.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,6 @@ class FirefoxExternalServices extends DefaultExternalServices {
FirefoxCom.requestSync("initPassiveLoading", null);
}

static async fallback(data) {
return FirefoxCom.requestAsync("fallback", data);
}

static reportTelemetry(data) {
FirefoxCom.request("reportTelemetry", JSON.stringify(data));
}
Expand Down

0 comments on commit 234aa9a

Please sign in to comment.