Skip to content

Commit b97b548

Browse files
committed
refactor: container children types
1 parent 19f4204 commit b97b548

2 files changed

Lines changed: 9 additions & 11 deletions

File tree

src/library-authoring/containers/ContainerRemover.test.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ describe('<ContainerRemover />', () => {
5959
({ axiosMock } = initializeMocks());
6060
});
6161

62-
afterEach(() => {
63-
jest.clearAllMocks();
64-
axiosMock.restore();
65-
});
66-
6762
it('triggers update container children api call when duplicates are present', async () => {
6863
const user = userEvent.setup();
6964
const url = getLibraryContainerChildrenApiUrl(mockGetContainerChildren.unitIdWithDuplicate);

src/library-authoring/data/apiHooks.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -736,15 +736,18 @@ export const useRestoreContainer = (containerId: string) => {
736736
/**
737737
* Get the metadata and children for a container in a library
738738
*/
739-
export const useContainerChildren = <T extends { id: string, isNew?: boolean }>(
740-
containerId?: string,
741-
published: boolean = false,
742-
) => (
739+
export const useContainerChildren = <ChildType extends {
740+
id: string;
741+
isNew?: boolean;
742+
} = api.LibraryBlockMetadata | api.Container>(
743+
containerId?: string,
744+
published: boolean = false,
745+
) => (
743746
useQuery({
744747
enabled: !!containerId,
745748
queryKey: libraryAuthoringQueryKeys.containerChildren(containerId!),
746-
queryFn: () => api.getLibraryContainerChildren<T>(containerId!, published),
747-
structuralSharing: (oldData: T[], newData: T[]) => {
749+
queryFn: () => api.getLibraryContainerChildren<ChildType>(containerId!, published),
750+
structuralSharing: (oldData: ChildType[], newData: ChildType[]) => {
748751
// This just sets `isNew` flag to new children components
749752
if (oldData) {
750753
const oldDataIds = oldData.map((obj) => obj.id);

0 commit comments

Comments
 (0)