Skip to content

chore: reduce dashboard requests from seeded data #13034

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Debug
  • Loading branch information
kylecarbs committed Apr 22, 2024
commit 60fed57a3d767c69607fcbb01c0b7088e3929182
6 changes: 3 additions & 3 deletions site/src/api/queries/entitlements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { getMetadataAsJSON } from "utils/metadata";
import { cachedQuery } from "./util";

const initialEntitlementsData = getMetadataAsJSON<Entitlements>("entitlements");
const ENTITLEMENTS_QUERY_KEY = ["entitlements"] as const;
const entitlementsQueryKey = ["entitlements"] as const;

export const entitlements = (): UseQueryOptions<Entitlements> => {
return {
...cachedQuery,
queryKey: ENTITLEMENTS_QUERY_KEY,
queryKey: entitlementsQueryKey,
queryFn: () => API.getEntitlements(),
initialData: initialEntitlementsData,
};
Expand All @@ -21,7 +21,7 @@ export const refreshEntitlements = (queryClient: QueryClient) => {
mutationFn: API.refreshEntitlements,
onSuccess: async () => {
await queryClient.invalidateQueries({
queryKey: ENTITLEMENTS_QUERY_KEY,
queryKey: entitlementsQueryKey,
});
},
};
Expand Down
6 changes: 3 additions & 3 deletions site/src/utils/metadata.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export const getMetadataAsJSON = <T extends NonNullable<unknown>>(
property: string,
): T | undefined => {
const appearance = document.querySelector(`meta[property=${property}]`);
const metadata = document.querySelector(`meta[property=${property}]`);

if (appearance) {
const rawContent = appearance.getAttribute("content");
if (metadata) {
const rawContent = metadata.getAttribute("content");

if (rawContent) {
try {
Expand Down
Loading