From 32c926b82bd1c7ab16fb11a64c40a7941910dc2d Mon Sep 17 00:00:00 2001 From: Xavier FACQ Date: Wed, 20 Sep 2023 11:04:02 +0200 Subject: [PATCH] Sometimes the contributor component is empty (#2240) --- src/hooks/useAdoptiumContributorsApi.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/hooks/useAdoptiumContributorsApi.tsx b/src/hooks/useAdoptiumContributorsApi.tsx index 85a957d27..fdb6f406c 100644 --- a/src/hooks/useAdoptiumContributorsApi.tsx +++ b/src/hooks/useAdoptiumContributorsApi.tsx @@ -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) @@ -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;