Skip to content

Commit

Permalink
Revise padding.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathewjordan committed Jan 12, 2024
1 parent 60b6f56 commit 235127e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/assets/js/components/Work/Work.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ const Work = ({ work }: { work: WorkType }) => {

const { token, expires } = dataDcApiToken?.dcApiToken || {};

const currentDate = new Date();
const expiresDate = new Date(expires);

useEffect(() => {
if (token) {
workDispatch({
Expand All @@ -35,7 +32,12 @@ const Work = ({ work }: { work: WorkType }) => {
}

const handleTokenUpdate = setInterval(() => {
if (currentDate >= expiresDate) {
const timePadding = 60000; // 1 minute
const currentDate = new Date();
const expiresDate = new Date(expires);
const expireDifference = expiresDate.getTime() - currentDate.getTime();
console.log(currentDate, expiresDate, expireDifference);
if (expireDifference < timePadding) {
refetchDcApiToken();
}
}, 100);
Expand Down

0 comments on commit 235127e

Please sign in to comment.