Skip to content

Commit 60bca82

Browse files
Merge pull request #111 from MobilityData/copilot/fix-license-detail-error
Fix race condition: defer license fetch until Firebase auth is ready
2 parents 63809a7 + 6fb71c2 commit 60bca82

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/app/screens/Feed/components/LicenseDialog.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
} from '../../../store/license-selectors';
2525
import { loadingLicense } from '../../../store/license-reducer';
2626
import { useTranslations } from 'next-intl';
27+
import { useAuthSession } from '../../../components/AuthSessionProvider';
2728

2829
export interface LicenseDialogProps {
2930
open: boolean;
@@ -43,12 +44,13 @@ export default function LicenseDialog({
4344
const status = useSelector(selectLicenseStatus);
4445
const license = useSelector(selectActiveLicense);
4546
const errors = useSelector(selectLicenseErrors);
47+
const { isAuthReady } = useAuthSession();
4648

4749
useEffect(() => {
48-
if (open && licenseId != undefined) {
50+
if (open && licenseId != undefined && isAuthReady) {
4951
dispatch(loadingLicense({ licenseId }));
5052
}
51-
}, [open, licenseId, dispatch]);
53+
}, [open, licenseId, dispatch, isAuthReady]);
5254

5355
const rulesData = [
5456
{
@@ -104,7 +106,7 @@ export default function LicenseDialog({
104106
</IconButton>
105107
</DialogTitle>
106108
<DialogContent dividers>
107-
{status === 'loading' && (
109+
{(status === 'loading' || (open && !isAuthReady)) && (
108110
<Box
109111
sx={{
110112
display: 'flex',

0 commit comments

Comments
 (0)