From dc5b4e369dbd62503854711fbf633467645d606d Mon Sep 17 00:00:00 2001 From: Gustav Eikaas Date: Thu, 23 May 2024 11:16:51 +0200 Subject: [PATCH] feat: attempted performance improvements powerbi --- .../src/lib/components/report/Report.tsx | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/packages/power-bi/src/lib/components/report/Report.tsx b/packages/power-bi/src/lib/components/report/Report.tsx index d8017fe6..a788edd4 100644 --- a/packages/power-bi/src/lib/components/report/Report.tsx +++ b/packages/power-bi/src/lib/components/report/Report.tsx @@ -1,12 +1,14 @@ -import { useSuspenseQuery } from '@tanstack/react-query'; +import { useQuery } from '@tanstack/react-query'; import { FusionPowerBiToken, FusionEmbedConfig } from '../../types'; import { IReportEmbedConfiguration, models } from 'powerbi-client'; import { LoadedReport } from '../loadedReport/LoadedReport'; import { PowerBiProps } from '../PowerBi'; +import { CircularProgress } from '@equinor/eds-core-react'; export function Report({ getEmbedInfo, getToken, reportUri, controller, filters, bookmark }: PowerBiProps) { - const { data: token } = useSuspenseQuery({ + + const { data: token, isLoading: isTokenLoading } = useQuery({ queryKey: [reportUri, 'token'], queryFn: ({ signal }) => getToken(reportUri, signal), refetchInterval: (query) => generateRefetchInterval(query.state.data), @@ -14,21 +16,32 @@ export function Report({ getEmbedInfo, getToken, reportUri, controller, filters, refetchOnWindowFocus: true, }); - const { data: embed } = useSuspenseQuery({ + const { data: embed, isLoading: isEmbedLoading, } = useQuery({ queryKey: [reportUri, 'embed'], queryFn: async ({ signal }) => { - const { embedUrl, reportId } = await getEmbedInfo(reportUri, token!.token, signal); - return generateEmbedConfig({ embedUrl, reportId }, token!.token, filters); + const { embedUrl, reportId } = await getEmbedInfo(reportUri, "", signal); + return { + embedUrl, + reportId + } }, }); + + if (isTokenLoading || isEmbedLoading) { + return
} + if (!embed) { throw new Error('No embed'); } + if (!token) { + throw new Error("No token") + } + return ( { if (bookmark) { rep.bookmarksManager.applyState(bookmark);