Skip to content

Commit 0baab3e

Browse files
Merge pull request #49 from MobilityData/fix/login-state-persist
fix: login -> close tab -> open new tab -> logout [error]: Redux store data not available
2 parents 0b93132 + 1ab38d2 commit 0baab3e

File tree

5 files changed

+22
-37
lines changed

5 files changed

+22
-37
lines changed

.github/lighthouserc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = {
99
`${previewBaseUrl}/feeds`,
1010
`${previewBaseUrl}/feeds/gtfs/mdb-2126`,
1111
`${previewBaseUrl}/feeds/gtfs_rt/mdb-2585`,
12-
`${previewBaseUrl}/gbfs/gbfs-flamingo_porirua`
12+
`${previewBaseUrl}/feeds/gbfs/gbfs-flamingo_porirua`
1313
],
1414
numberOfRuns: 1, // 1 to speed up the CI process but can be increased for more reliable results
1515
settings: {

src/app/[locale]/[...slug]/page.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@
55
import { type ReactNode, use, useEffect } from 'react';
66
import dynamic from 'next/dynamic';
77
import { PersistGate } from 'redux-persist/integration/react';
8-
import { persistStore } from 'redux-persist';
9-
import { store } from '../../store/store';
8+
import { persistor } from '../../store/store';
109
import { useAppDispatch } from '../../hooks';
1110
import { resetProfileErrors } from '../../store/profile-reducer';
1211

1312
const App = dynamic(async () => await import('../../App'), { ssr: false });
1413

15-
const persistor = persistStore(store);
16-
1714
interface PageProps {
1815
params: Promise<{
1916
locale: string;

src/app/components/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export default function DrawerAppBar(): React.ReactElement {
218218
: '/assets/MOBILTYDATA_logo_purple_M.png'
219219
}
220220
alt='MobilityData logo'
221-
width={45}
221+
width={45 * 1.05} // aspect ratio of the logo is slightly off, adjust width to prevent layout shift between themes
222222
height={45}
223223
priority
224224
fetchPriority='high'

src/app/components/HeaderMobileDrawer.tsx

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { mobileNavElementStyle } from './Header.style';
2626
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
2727
import { useRemoteConfig } from '../context/RemoteConfigProvider';
2828
import { useTranslations } from 'next-intl';
29+
import Image from 'next/image';
2930

3031
const websiteTile = 'MobilityDatabase';
3132

@@ -55,37 +56,18 @@ export default function DrawerContent({
5556
router.push('/');
5657
}}
5758
>
58-
{theme.palette.mode === 'light' ? (
59-
<picture style={{ display: 'flex' }}>
60-
<source
61-
src='/assets/MOBILTYDATA_logo_light_blue_M.png'
62-
type='image/png'
63-
height={40}
64-
width={40}
65-
/>
66-
<img
67-
alt='MobilityData logo'
68-
src='/assets/MOBILTYDATA_logo_light_blue_M.png'
69-
height={40}
70-
width={40}
71-
/>
72-
</picture>
73-
) : (
74-
<picture style={{ display: 'flex' }}>
75-
<source
76-
src='/assets/MOBILTYDATA_logo_purple_M.png'
77-
type='image/png'
78-
height={40}
79-
width={40}
80-
/>
81-
<img
82-
alt='MobilityData logo'
83-
src='/assets/MOBILTYDATA_logo_purple_M.png'
84-
height={40}
85-
width={40}
86-
/>
87-
</picture>
88-
)}
59+
<Image
60+
src={
61+
theme.palette.mode === 'light'
62+
? '/assets/MOBILTYDATA_logo_light_blue_M.png'
63+
: '/assets/MOBILTYDATA_logo_purple_M.png'
64+
}
65+
alt='MobilityData logo'
66+
width={40 * 1.05} // aspect ratio of the logo is slightly off, adjust width to prevent layout shift between themes
67+
height={40}
68+
priority
69+
fetchPriority='high'
70+
/>
8971

9072
<Typography
9173
component={'h2'}

src/app/store/store.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
persistReducer,
3+
persistStore,
34
FLUSH,
45
REHYDRATE,
56
PAUSE,
@@ -83,6 +84,11 @@ if (typeof window !== 'undefined' && (window as any).Cypress) {
8384

8485
sagaMiddleware.run(rootSaga);
8586

87+
// Create the persistor at the store level so rehydration and
88+
// state-persistence happen on every page load, not just on the
89+
// legacy catch-all route.
90+
export const persistor = persistStore(store);
91+
8692
export type RootState = ReturnType<typeof store.getState>;
8793
export type AppDispatch = typeof store.dispatch;
8894
export type AppThunk<ReturnType = void> = ThunkAction<

0 commit comments

Comments
 (0)