Skip to content

Commit

Permalink
wip: Match GitHub and local react apps
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Oct 25, 2023
1 parent ad6c480 commit 8ba6245
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions editor.planx.uk/src/routes/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TYPES as NodeTypes } from "@planx/components/types";
import gql from "graphql-tag";
import { hasFeatureFlag } from "lib/featureFlags";
import { NaviRequest, NotFoundError } from "navi";
import pMemoize from "p-memoize";
// import pMemoize from "p-memoize";
import { useStore } from "pages/FlowEditor/lib/store";
import { ApplicationPath } from "types";

Expand Down Expand Up @@ -63,15 +63,17 @@ export const isPreviewOnlyDomain = PREVIEW_ONLY_DOMAINS.some((domain) =>
window.location.hostname.endsWith(domain),
);

// TODO: is graphql actually caching this without p-memoize?
const QUERY_GET_TEAM_BY_DOMAIN = gql`
query GetTeamByDomain($domain: String!) {
teams(limit: 1, where: { domain: { _eq: $domain } }) {
id
slug
}
}
`;

export const getTeamFromDomain = pMemoize(async (domain: string) => {
export const getTeamFromDomain = async (domain: string) => {
const {
data: { teams },
} = await publicClient.query({
Expand All @@ -82,7 +84,7 @@ export const getTeamFromDomain = pMemoize(async (domain: string) => {
});

return teams?.[0]?.slug;
});
};

/**
* Prevents accessing a different team than the one associated with the custom domain.
Expand Down

0 comments on commit 8ba6245

Please sign in to comment.