Skip to content
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

FE: Fix refetching data on window focus #380

Merged
merged 9 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
4 changes: 4 additions & 0 deletions frontend/src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ export const QUERY_REFETCH_OFF_OPTIONS = {
refetchIntervalInBackground: false,
};

export const QUERY_REFETCH_ON_WINDOW_FOCUS_OFF_OPTION = {
refetchOnWindowFocus: false,
masonwoodford marked this conversation as resolved.
Show resolved Hide resolved
};

// Cluster Form Constants
export const AUTH_OPTIONS = [
{ value: 'SASL/JAAS', label: 'SASL/JAAS' },
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lib/hooks/api/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
SCHEMA_QUERY_KEY,
SCHEMAS_VERSION_QUERY_KEY,
} from 'lib/queries';
import { QUERY_REFETCH_ON_WINDOW_FOCUS_OFF_OPTION } from 'lib/constants';
import {
CompatibilityLevel,
GetAllVersionsBySubjectRequest,
Expand All @@ -28,6 +29,7 @@ export function useGetLatestSchema(param: GetLatestSchemaRequest) {
param.subject,
],
queryFn: () => schemasApiClient.getLatestSchema(param),
...QUERY_REFETCH_ON_WINDOW_FOCUS_OFF_OPTION,
});
}

Expand Down
13 changes: 11 additions & 2 deletions frontend/src/lib/hooks/api/topics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
TopicFormDataRaw,
TopicFormFormattedParams,
} from 'lib/interfaces/topic';
import { QUERY_REFETCH_ON_WINDOW_FOCUS_OFF_OPTION } from 'lib/constants';

export const topicKeys = {
all: (clusterName: ClusterName) =>
Expand Down Expand Up @@ -50,10 +51,18 @@ export function useTopics(props: GetTopicsRequest) {
);
}
export function useTopicDetails(props: GetTopicDetailsRequest) {
return useQuery(topicKeys.details(props), () => api.getTopicDetails(props));
return useQuery(
topicKeys.details(props),
() => api.getTopicDetails(props),
QUERY_REFETCH_ON_WINDOW_FOCUS_OFF_OPTION
masonwoodford marked this conversation as resolved.
Show resolved Hide resolved
);
}
export function useTopicConfig(props: GetTopicDetailsRequest) {
return useQuery(topicKeys.config(props), () => api.getTopicConfigs(props));
return useQuery(
topicKeys.config(props),
() => api.getTopicConfigs(props),
QUERY_REFETCH_ON_WINDOW_FOCUS_OFF_OPTION
);
}
export function useTopicConsumerGroups(props: GetTopicDetailsRequest) {
return useQuery(topicKeys.consumerGroups(props), () =>
Expand Down
Loading