Skip to content

Commit

Permalink
fix: Check fetching condition first
Browse files Browse the repository at this point in the history
...to avoid showing stale data and updating the localised content once the data fetches in the background. This is needed as we do not reload the page via changing pathname when redirecting to versioned cube.
  • Loading branch information
bprusinowski committed Sep 12, 2023
1 parent 8f27098 commit cf7f78b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/browse/datatable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export const DataSetPreviewTable = ({
title: string;
dimensions: DimensionMetadataFragment[];
measures: DimensionMetadataFragment[];
observations: Observation[];
observations: Observation[] | undefined;
}) => {
const headers = useMemo(() => {
return getSortedColumns([...dimensions, ...measures]);
Expand Down
14 changes: 7 additions & 7 deletions app/browser/dataset-preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,13 @@ export const DataSetPreview = ({
window.scrollTo({ top: 0 });
}, []);

if (metadata?.dataCubeByIri) {
if (fetching) {
return (
<Flex className={classes.loadingWrapper}>
<Loading />
</Flex>
);
} else if (metadata?.dataCubeByIri) {
const { dataCubeByIri } = metadata;

return (
Expand Down Expand Up @@ -188,12 +194,6 @@ export const DataSetPreview = ({
</Paper>
</Flex>
);
} else if (fetching) {
return (
<Flex className={classes.loadingWrapper}>
<Loading />
</Flex>
);
} else {
return (
<Flex className={classes.loadingWrapper}>
Expand Down
2 changes: 1 addition & 1 deletion app/components/use-redirect-to-versioned-cube.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const useRedirectToVersionedCube = ({

if (resp) {
router.replace({
pathname: `/browse`,
pathname: "browse",
query: {
...router.query,
...(router.query.iri ? { iri: resp.iri } : { dataset: resp.iri }),
Expand Down

0 comments on commit cf7f78b

Please sign in to comment.