Skip to content

Commit

Permalink
fix: avoid renewing session every second
Browse files Browse the repository at this point in the history
  • Loading branch information
jorilindell committed Jun 12, 2024
1 parent dabd64a commit 0790f15
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/domain/signupGroup/reservationTimer/ReservationTimer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable max-len */
import pick from 'lodash/pick';
import { useRouter } from 'next/router';
import { getSession } from 'next-auth/react';
import { useSession } from 'next-auth/react';
import { useTranslation } from 'next-i18next';
import React, { useCallback, useMemo, useRef, useState } from 'react';

Expand Down Expand Up @@ -65,6 +65,7 @@ const ReservationTimer: React.FC<ReservationTimerProps> = ({
signups,
}) => {
const isExpiringModalAlreadyDisplayed = useRef(false);
const { data: session } = useSession();
const router = useRouter();
const { t } = useTranslation('reservation');
const { setAccessibilityText } = useAccessibilityNotificationContext();
Expand Down Expand Up @@ -149,7 +150,7 @@ const ReservationTimer: React.FC<ReservationTimerProps> = ({
}
},
});
} else if (!data) {
} else {
onDataNotFound && onDataNotFound();
}
} else if (data) {
Expand All @@ -170,7 +171,6 @@ const ReservationTimer: React.FC<ReservationTimerProps> = ({
const clearDataIfReservationExpired = async () => {
/* istanbul ignore else */
if (timerEnabled.current && !callbacksDisabled) {
const session = await getSession();
const data = getSeatsReservationData(registrationId);
const newTimeLeft = getRegistrationTimeLeft(data);

Expand Down Expand Up @@ -205,6 +205,7 @@ const ReservationTimer: React.FC<ReservationTimerProps> = ({
callbacksDisabled,
disableCallbacks,
registrationId,
session,
setOpenModal,
setTimeLeft,
timeLeft,
Expand Down

0 comments on commit 0790f15

Please sign in to comment.