Skip to content

Commit

Permalink
Update redirect criteria so that the shouldSkipPlaceOverview functi…
Browse files Browse the repository at this point in the history
…on is only called once, and it is only called in a context where we are sure that the pageMetaData exists.
  • Loading branch information
nick-next committed Nov 15, 2024
1 parent 4387d55 commit c93718d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions static/js/apps/explore/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,14 @@ export function App(props: { isDemo: boolean }): JSX.Element {
sessionId: "session" in fulfillData ? fulfillData["session"]["id"] : "",
svSource: fulfillData["svSource"],
};
let isPendingRedirect = false;
if (
pageMetadata &&
pageMetadata.pageConfig &&
pageMetadata.pageConfig.categories
) {
if (shouldSkipPlaceOverview(pageMetadata)) {
isPendingRedirect = shouldSkipPlaceOverview(pageMetadata);
if (isPendingRedirect) {
const placeDcid = pageMetadata.place.dcid;
const url = `/place/${placeDcid}`;
window.location.replace(url);
Expand Down Expand Up @@ -263,9 +265,7 @@ export function App(props: { isDemo: boolean }): JSX.Element {
sessionId: pageMetadata.sessionId,
});
setLoadingStatus(
shouldSkipPlaceOverview(pageMetadata)
? LoadingStatus.LOADING
: LoadingStatus.SUCCESS
isPendingRedirect ? LoadingStatus.LOADING : LoadingStatus.SUCCESS
);
}

Expand Down

0 comments on commit c93718d

Please sign in to comment.