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

[Discover] Fix refresh on index #8121

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,18 @@ export const useIndexPattern = (services: DiscoverViewServices) => {
let isMounted = true;

const handleIndexPattern = async () => {
if (isQueryEnhancementEnabled && query?.dataset) {
const pattern = await data.indexPatterns.get(query.dataset.id);
if (isQueryEnhancementEnabled && query.dataset) {
let pattern = await data.indexPatterns.get(
query.dataset.id,
query.dataset.type !== 'INDEX_PATTERN'
);
if (!pattern) {
await data.query.queryString.getDatasetService().cacheDataset(query.dataset);
pattern = await data.indexPatterns.get(
query.dataset.id,
query.dataset.type !== 'INDEX_PATTERN'
);
}

if (isMounted && pattern) {
setIndexPattern(pattern);
Expand Down Expand Up @@ -95,7 +105,8 @@ export const useIndexPattern = (services: DiscoverViewServices) => {
store,
toastNotifications,
uiSettings,
query?.dataset,
query.dataset,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

query will never be undefined?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it will be default query if not passed in

data.query.queryString,
]);

return indexPattern;
Expand Down
Loading