-
Notifications
You must be signed in to change notification settings - Fork 12
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
ref: Optimize file fetching code #96
Conversation
headers: { | ||
"Accept": "application/json", | ||
}, | ||
}).then((response) => response.json()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🫡
if (commit.length === 7) { | ||
const commitLink = document.querySelector( | ||
`[href^="/${groups.owner}/${groups.repo}/tree/${commit}"]` | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the long sha can be found inside a few links on this page, that's what this code extracts.
@@ -232,40 +269,6 @@ async function process(metadata: FileMetadata): Promise<void> { | |||
animateAndAnnotateLines(noVirtLineSelector, annotateLine); | |||
} | |||
|
|||
async function promptPastReport(metadata: FileMetadata): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There will never be a need for this code anymore. This was called when the metadata for a branch gave the HEAD commit and there was no coverage for that HEAD commit. If you're on a branch now, Codecov will handle this on the API side and give you the last good coverage.
.closest("div")!; | ||
const dropdownButton = editButton.cloneNode(true) as HTMLElement; | ||
const textNode: HTMLElement = dropdownButton.querySelector('[data-component="IconButton"]')!; | ||
// Build the button out of the Raw/copy/download button group |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're looking at a file at a commit, the old button we were building from does not exist. I adjusted the code to use a button that exists on both types of view (the raw/copy/download group). Additionally, I made the code a bit safer by removing !
s
While looking around in here I noticed we were doing a whole extra fetch to get the metadata for the file when all of the info we need was already present on the page. This PR updates the code to remove that fetch. Additionally, adds support for file coverage when browsing at a specific commit, this was previously not supported.