From 39658c8b02ee9de0a2d5cfa3ded964e23dea7ca6 Mon Sep 17 00:00:00 2001 From: Wes Date: Fri, 4 Oct 2024 10:06:22 -0700 Subject: [PATCH] fix: enum syntax highlighting - also fix refreshing of modules when schema changes --- frontend/console/src/api/modules/use-modules.ts | 16 +++------------- frontend/console/src/api/schema/use-schema.ts | 4 ++-- .../src/features/modules/schema/Schema.tsx | 2 +- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/frontend/console/src/api/modules/use-modules.ts b/frontend/console/src/api/modules/use-modules.ts index d71d1f7f14..fcfe7b9f91 100644 --- a/frontend/console/src/api/modules/use-modules.ts +++ b/frontend/console/src/api/modules/use-modules.ts @@ -1,6 +1,5 @@ import { Code, ConnectError } from '@connectrpc/connect' -import { useQuery, useQueryClient } from '@tanstack/react-query' -import { useEffect } from 'react' +import { useQuery } from '@tanstack/react-query' import { useClient } from '../../hooks/use-client' import { ConsoleService } from '../../protos/xyz/block/ftl/v1/console/console_connect' import { useSchema } from '../schema/use-schema' @@ -9,16 +8,7 @@ const useModulesKey = 'modules' export const useModules = () => { const client = useClient(ConsoleService) - const queryClient = useQueryClient() - const { data: schemaData } = useSchema() - - useEffect(() => { - if (schemaData) { - queryClient.invalidateQueries({ - queryKey: [useModulesKey], - }) - } - }, [schemaData, queryClient]) + const { data: schemaData, dataUpdatedAt: schemaUpdatedAt } = useSchema() const fetchModules = async (signal: AbortSignal) => { try { @@ -38,7 +28,7 @@ export const useModules = () => { } return useQuery({ - queryKey: [useModulesKey], + queryKey: [useModulesKey, schemaUpdatedAt], queryFn: async ({ signal }) => fetchModules(signal), enabled: !!schemaData, }) diff --git a/frontend/console/src/api/schema/use-schema.ts b/frontend/console/src/api/schema/use-schema.ts index bcd58c8f3a..7c600e4523 100644 --- a/frontend/console/src/api/schema/use-schema.ts +++ b/frontend/console/src/api/schema/use-schema.ts @@ -1,5 +1,5 @@ import { Code, ConnectError } from '@connectrpc/connect' -import { useQuery, useQueryClient } from '@tanstack/react-query' +import { type UseQueryResult, useQuery, useQueryClient } from '@tanstack/react-query' import { useClient } from '../../hooks/use-client.ts' import { useVisibility } from '../../hooks/use-visibility.ts' import { ControllerService } from '../../protos/xyz/block/ftl/v1/ftl_connect.ts' @@ -9,7 +9,7 @@ const streamingSchemaKey = 'streamingSchema' const currentDeployments: Record = {} const schemaMap: Record = {} -export const useSchema = () => { +export const useSchema = (): UseQueryResult => { const client = useClient(ControllerService) const queryClient = useQueryClient() const isVisible = useVisibility() diff --git a/frontend/console/src/features/modules/schema/Schema.tsx b/frontend/console/src/features/modules/schema/Schema.tsx index 97f952f840..b9d567640a 100644 --- a/frontend/console/src/features/modules/schema/Schema.tsx +++ b/frontend/console/src/features/modules/schema/Schema.tsx @@ -12,7 +12,7 @@ function maybeRenderDeclName(token: string, declType: string, tokens: string[], return } if (declType === 'enum') { - return [, token.slice(-1)] + return [] } if (declType === 'verb') { return