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
Introduces a new function to determine if a particular document within a multi-doc page is available in the recap archive.
  • Loading branch information
ERosendo committed Oct 1, 2024
1 parent dc15a95 commit f92c339
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.docId) {
this.docId = await getPacerDocIdFromPartialId(
this.tabId,
partialDocId
);
}

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

const recapLinks = await dispatchBackgroundFetch({
action: 'getAvailabilityForDocuments',
data: {
docket_entry__docket__court: clCourt,
pacer_doc_id__in: PACER.cleanPacerDocId(this.docId),
},
});
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.docId,
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 f92c339

Please sign in to comment.