-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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] Less field list loading #147825
Changes from 1 commit
231ba16
0dc8292
a4ee983
0cd7c17
2be0396
73636cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,13 +93,6 @@ export function DiscoverMainRoute(props: Props) { | |
return; | ||
} | ||
|
||
const defaultDataView = await data.dataViews.getDefaultDataView(); | ||
|
||
if (!defaultDataView) { | ||
setShowNoDataPage(true); | ||
return; | ||
} | ||
|
||
const { appStateContainer } = getState({ history, savedSearch: nextSavedSearch, services }); | ||
const { index } = appStateContainer.getState(); | ||
const ip = await loadDataView( | ||
|
@@ -111,7 +104,6 @@ export function DiscoverMainRoute(props: Props) { | |
|
||
const ipList = ip.list; | ||
const dataViewData = resolveDataView(ip, nextSavedSearch.searchSource, toastNotifications); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
await data.dataViews.refreshFields(dataViewData); | ||
setDataViewList(ipList); | ||
|
||
return dataViewData; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,9 +38,6 @@ export function findDataViewById( | |
dataViews: DataViewListItem[], | ||
id: string | ||
): DataViewListItem | undefined { | ||
if (!Array.isArray(dataViews) || !id) { | ||
return; | ||
} | ||
return dataViews.find((o) => o.id === id); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed this code since its enforced by type safety. Let me know if there's some reason why this shouldn't be done. |
||
} | ||
|
||
|
@@ -104,9 +101,10 @@ export async function loadDataView( | |
fetchId = dataViewSpec.id!; | ||
} | ||
|
||
let fetchedDataView: DataView | undefined; | ||
// try to fetch adhoc data view first | ||
try { | ||
const fetchedDataView = fetchId ? await dataViews.get(fetchId) : undefined; | ||
fetchedDataView = fetchId ? await dataViews.get(fetchId) : undefined; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously this code was loading a data view, checking if it was adhoc, then tossing the result. Now we hold on to it in case its the data view we wanted to load. |
||
if (fetchedDataView && !fetchedDataView.isPersisted()) { | ||
return { | ||
list: dataViewList || [], | ||
|
@@ -122,12 +120,14 @@ export async function loadDataView( | |
} catch (e) {} | ||
|
||
// fetch persisted data view | ||
const actualId = getDataViewId(fetchId, dataViewList, config.get('defaultIndex')); | ||
return { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need |
||
list: dataViewList || [], | ||
loaded: await dataViews.get(actualId), | ||
loaded: fetchedDataView | ||
? fetchedDataView | ||
: // we can be certain that the data view exists due to an earlier hasData check | ||
((await dataViews.getDefaultDataView()) as DataView), | ||
stateVal: fetchId, | ||
stateValFound: !!fetchId && actualId === fetchId, | ||
stateValFound: !!fetchId && !!fetchedDataView, | ||
}; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This functionality duplicates what
dataViews.hasData
is doing. If it doesn't work, it should be fixed.