Skip to content

Commit

Permalink
adress review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
v-rocheleau committed Jan 9, 2024
1 parent 265e5df commit eabf187
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ import {
import YourSessionWorker as SessionWorker from "../session.worker"
import { AUTH_CALLBACK_URL, BENTO_URL_NO_TRAILING_SLASH, CLIENT_ID, OPENID_CONFIG_URL } from "../config";

// Session worker creator function must be in a constant for useSessionWorkerTokenRefresh
const createSessionWorker = () => new SessionWorker();

const App = () => {
const dispatch = useDispatch();
Expand Down Expand Up @@ -87,7 +89,7 @@ const App = () => {
useSessionWorkerTokenRefresh(
CLIENT_ID,
sessionWorker,
() => new SessionWorker(),
createSessionWorker,
fetchUserDependentData(nop),
);

Expand Down
12 changes: 9 additions & 3 deletions src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const useOpenIdConfig = (openIdConfigUrl: string) => {

useEffect(() => {
dispatch(fetchOpenIdConfiguration(openIdConfigUrl));
}, [dispatch]);
}, [dispatch, openIdConfigUrl]);

return useSelector((state: RootState) => state.openIdConfiguration.data);
}
Expand Down Expand Up @@ -92,7 +92,13 @@ export const useSessionWorkerTokenRefresh = (
});
sessionWorkerRef.current = sw;
}
}, [dispatch]);

return () => {
if (sessionWorkerRef.current) {
sessionWorkerRef.current.terminate();
}
}
}, [dispatch, createWorker, fetchUserDependentData]);
};

interface OpenIdConfig {
Expand Down Expand Up @@ -126,7 +132,7 @@ export const useOpenSignInWindowCallback = (
`${windowFeatures}, top=${popupTop}, left=${popupLeft}`,
);
})();
}, [openIdConfig]);
}, [openIdConfig, clientId, authCallbackUrl, windowFeatures]);
};

export const usePopupOpenerAuthCallback = (applicationUrl: string) => {
Expand Down
2 changes: 0 additions & 2 deletions src/performAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,3 @@ export const checkIsInAuthPopup = (applicationUrl: string): boolean => {
return false;
}
}


0 comments on commit eabf187

Please sign in to comment.