Skip to content
Snippets Groups Projects
Unverified Commit 56469a29 authored by Alexander Polyankin's avatar Alexander Polyankin Committed by GitHub
Browse files

Fix loading metadata for models (#41074)

parent c8bbe471
No related branches found
No related tags found
No related merge requests found
......@@ -285,6 +285,8 @@ export const setup = async ({
},
);
await waitForLoadingRequests(getState);
await waitForLoaderToBeRemoved();
await waitForLoadingRequests(getState);
return {
......
......@@ -2,6 +2,7 @@ import { loadMetadataForDependentItems } from "metabase/redux/metadata";
import { getMetadata } from "metabase/selectors/metadata";
import * as Lib from "metabase-lib";
import Question from "metabase-lib/v1/Question";
import { getQuestionVirtualTableId } from "metabase-lib/v1/metadata/utils/saved-questions";
import type { Card } from "metabase-types/api";
import type { Dispatch, GetState } from "metabase-types/store";
......@@ -13,11 +14,16 @@ export const loadMetadataForCard =
(card: Card, options?: LoadMetadataOptions) =>
async (dispatch: Dispatch, getState: GetState) => {
const question = new Question(card, getMetadata(getState()));
const dependencies = Lib.dependentMetadata(question.query());
const loadAdhocMetadata =
question.isSaved() && question.type() !== "question";
const dependencies = [...Lib.dependentMetadata(question.query())];
if (loadAdhocMetadata) {
const tableId = getQuestionVirtualTableId(question.id());
dependencies.push({ id: tableId, type: "table" });
}
await dispatch(loadMetadataForDependentItems(dependencies, options));
// metadata for an ad-hoc question based on this question
if (question.isSaved() && question.type() !== "question") {
if (loadAdhocMetadata) {
const questionWithMetadata = new Question(card, getMetadata(getState()));
const adhocQuestion = questionWithMetadata.composeQuestionAdhoc();
const adhocDependencies = Lib.dependentMetadata(adhocQuestion.query());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment