Skip to content

Commit

Permalink
Sometimes the contributor component is empty (#2240)
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierfacq authored Sep 20, 2023
1 parent dce1fbb commit 32c926b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/hooks/useAdoptiumContributorsApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ async function fetchRandomContributor() {
let needToRefetch = false;
const ONE_MONTH_MS = 2592000000;

const wlsMaxContributors = `${repoToCheck}_max_contributors`;
const wlsFetchDate = `${repoToCheck}_fetch_date`;

if (window.localStorage) {
const maxContributorsStored =
window.localStorage.getItem('max_contributors');
const fetchDateStored = window.localStorage.getItem('fetch_date');
const maxContributorsStored = window.localStorage.getItem(wlsMaxContributors);
const fetchDateStored = window.localStorage.getItem(wlsFetchDate);

maxContributors = maxContributorsStored
? parseInt(maxContributorsStored, 10)
Expand All @@ -126,8 +128,8 @@ async function fetchRandomContributor() {
}

if (window.localStorage) {
window.localStorage.setItem('fetch_date', String(Date.now()));
window.localStorage.setItem('max_contributors', String(lastPage));
window.localStorage.setItem(wlsFetchDate, String(Date.now()));
window.localStorage.setItem(wlsMaxContributors, String(lastPage));
}

return contributor;
Expand Down

0 comments on commit 32c926b

Please sign in to comment.