Skip to content

Commit dcc5036

Browse files
committed
fix: fixes from merge
1 parent 08f550b commit dcc5036

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

src/library-authoring/containers/UnitInfo.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ const UnitInfo = () => {
8888
) ? sidebarTab : defaultTab.unit;
8989

9090
const unitId = sidebarComponentInfo?.id;
91+
92+
// istanbul ignore if: this should never happen
93+
if (!unitId) {
94+
throw new Error('unitId is required');
95+
}
96+
9197
const { data: container } = useContainer(unitId);
9298

9399
const handleOpenUnit = useCallback(() => {

src/library-authoring/data/apiHooks.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -609,13 +609,14 @@ export const useCreateLibraryContainer = (libraryId: string) => {
609609
/**
610610
* Get the metadata for a container in a library
611611
*/
612-
export const useContainer = (containerId?: string) => (
613-
useQuery({
612+
export const useContainer = (containerId: string) => {
613+
const libraryId = getLibraryId(containerId);
614+
return useQuery({
614615
enabled: !!containerId,
615-
queryKey: containerQueryKeys.container(containerId),
616+
queryKey: libraryAuthoringQueryKeys.container(libraryId, containerId),
616617
queryFn: () => getContainerMetadata(containerId!),
617-
})
618-
);
618+
});
619+
};
619620

620621
/**
621622
* Use this mutation to update the fields of a container in a library
@@ -673,7 +674,7 @@ export const useContainerChildren = (containerId: string) => {
673674
queryKey: libraryAuthoringQueryKeys.containerChildren(libraryId, containerId),
674675
queryFn: () => getLibraryContainerChildren(containerId!),
675676
});
676-
);
677+
};
677678

678679
/**
679680
* Use this mutation to add components to a container

src/library-authoring/units/LibraryUnitBlocks.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import TagCount from '../../generic/tag-count';
1818
import { useLibraryContext } from '../common/context/LibraryContext';
1919
import ComponentMenu from '../components';
2020
import { LibraryBlockMetadata } from '../data/api';
21-
import { containerQueryKeys, useContainerChildren } from '../data/apiHooks';
21+
import { libraryAuthoringQueryKeys, useContainerChildren } from '../data/apiHooks';
2222
import { LibraryBlock } from '../LibraryBlock';
2323
import { useLibraryRoutes } from '../routes';
2424
import messages from './messages';
@@ -31,6 +31,7 @@ export const LibraryUnitBlocks = () => {
3131
const { navigateTo } = useLibraryRoutes();
3232

3333
const {
34+
libraryId,
3435
unitId,
3536
showOnlyPublished,
3637
componentId,
@@ -55,7 +56,6 @@ export const LibraryUnitBlocks = () => {
5556
error,
5657
} = useContainerChildren(unitId);
5758

58-
5959
useEffect(() => setOrderedBlocks(blocks || []), [blocks]);
6060

6161
if (isLoading) {
@@ -75,7 +75,7 @@ export const LibraryUnitBlocks = () => {
7575
};
7676

7777
const onTagSidebarClose = () => {
78-
queryClient.invalidateQueries(containerQueryKeys.children(unitId));
78+
queryClient.invalidateQueries(libraryAuthoringQueryKeys.containerChildren(libraryId, unitId));
7979
closeManageTagsDrawer();
8080
};
8181

0 commit comments

Comments
 (0)