Skip to content

Commit

Permalink
feat(appellate): Adds helper function to check document availability …
Browse files Browse the repository at this point in the history
…within multi-doc pages
  • Loading branch information
ERosendo committed Sep 30, 2024
1 parent 77f9778 commit f781a67
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/appellate/appellate.js
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,50 @@ AppellateDelegate.prototype.handleCombinedPdfPageView = async function () {
document.body.appendChild(warning);
return;
}

await this.checkSingleDocInCombinedPDFPage();
};

AppellateDelegate.prototype.checkSingleDocInCombinedPDFPage = async function(){
let clCourt = PACER.convertToCourtListenerCourt(this.court);
// Retrieves a partial document ID from the URL parameter named `"dls"`. It's
// important to note that this value might not be the complete document ID.
// It could potentially be a shortened version of the full ID.
let urlParams = new URLSearchParams(window.location.search);
let partialDocId = urlParams.get('dls').split(',')[0];

// If the `this.pacer_doc_id` property is not already set, attempt to retrieve
// it using the previously extracted partial document ID. The returned full
// document ID is then stored in the `this.pacer_doc_id` property for
// subsequent use.
if (!this.pacer_doc_id) {
this.pacer_doc_id = await getPacerDocIdFromPartialId(
this.tabId,
partialDocId
);
}

// If we don't have this.pacer_doc_id at this point, punt.
if (!this.pacer_doc_id) return;

const recapLinks = await dispatchBackgroundFetch({
action: 'getAvailabilityForDocuments',
data: {
docket_entry__docket__court: clCourt,
pacer_doc_id__in: this.pacer_doc_id,
},
});
if (!recapLinks.results.length) return;
console.info(
'RECAP: Got results from API. Processing results to insert link'
);
let result = recapLinks.results.filter(
(doc) => doc.pacer_doc_id === this.pacer_doc_id,
this
);
if (!result.length) return;

insertAvailableDocBanner(result[0].filepath_local, 'body');
};

// If this page offers a single document, intercept navigation to the document
Expand Down

0 comments on commit f781a67

Please sign in to comment.