Skip to content

Commit

Permalink
Merge pull request #95 from virtualidentityag/fix/registration-preloa…
Browse files Browse the repository at this point in the history
…d-session-data

fix: possible race condition while loading topic data
  • Loading branch information
janrembold authored Apr 22, 2024
2 parents cc49e9b + afc5706 commit 0fd48b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,7 @@ export const AgencySelectionResults = ({
return;
}

if (
// invalid agencyId, needs to be removed
selectedAgency &&
results?.length === 0
) {
if (results?.length === 0) {
setDisabledNextButton(true);
onChange({
agency: undefined
Expand Down
5 changes: 4 additions & 1 deletion src/globalState/provider/RegistrationProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export function RegistrationProvider({ children }: PropsWithChildren<{}>) {

const { url } = useRouteMatch();

const [loading, setLoading] = useState<boolean>(true);
const [disabledNextButton, setDisabledNextButton] = useState<boolean>(true);
const [hasTopicError, setHasTopicError] = useState<boolean>(false);
const [hasAgencyError, setHasAgencyError] = useState<boolean>(false);
Expand Down Expand Up @@ -144,6 +145,7 @@ export function RegistrationProvider({ children }: PropsWithChildren<{}>) {
(async () => {
const registrationData =
getSessionStorageData() as RegistrationData;

if (registrationData.mainTopicId) {
registrationData.mainTopic = await apiGetTopicById(
registrationData.mainTopicId
Expand All @@ -161,6 +163,7 @@ export function RegistrationProvider({ children }: PropsWithChildren<{}>) {
);
}
setRegistrationData(registrationData);
setLoading(false);
})();
}, []);

Expand Down Expand Up @@ -250,7 +253,7 @@ export function RegistrationProvider({ children }: PropsWithChildren<{}>) {
]
);

if (!loaded) return null;
if (!loaded || loading) return null;

return (
<RegistrationContext.Provider value={context}>
Expand Down

0 comments on commit 0fd48b5

Please sign in to comment.