@@ -736,29 +736,32 @@ 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 } > ( containerId ?: string , published : boolean = false ) => (
740- useQuery ( {
741- enabled : ! ! containerId ,
742- queryKey : libraryAuthoringQueryKeys . containerChildren ( containerId ! ) ,
743- queryFn : ( ) => api . getLibraryContainerChildren < T > ( containerId ! , published ) ,
744- structuralSharing : ( oldData : T [ ] , newData : T [ ] ) => {
739+ export const useContainerChildren = < T extends { id : string , isNew ?: boolean } > (
740+ containerId ?: string ,
741+ published : boolean = false ,
742+ ) => (
743+ useQuery ( {
744+ enabled : ! ! containerId ,
745+ queryKey : libraryAuthoringQueryKeys . containerChildren ( containerId ! ) ,
746+ queryFn : ( ) => api . getLibraryContainerChildren < T > ( containerId ! , published ) ,
747+ structuralSharing : ( oldData : T [ ] , newData : T [ ] ) => {
745748 // This just sets `isNew` flag to new children components
746- if ( oldData ) {
747- const oldDataIds = oldData . map ( ( obj ) => obj . id ) ;
748- // eslint-disable-next-line no-param-reassign
749- newData = newData . map ( ( newObj ) => {
750- if ( ! oldDataIds . includes ( newObj . id ) ) {
749+ if ( oldData ) {
750+ const oldDataIds = oldData . map ( ( obj ) => obj . id ) ;
751+ // eslint-disable-next-line no-param-reassign
752+ newData = newData . map ( ( newObj ) => {
753+ if ( ! oldDataIds . includes ( newObj . id ) ) {
751754 // Set isNew = true if we have new child on refetch
752755 // eslint-disable-next-line no-param-reassign
753- newObj . isNew = true ;
754- }
755- return newObj ;
756- } ) ;
757- }
758- return replaceEqualDeep ( oldData , newData ) ;
759- } ,
760- } )
761- ) ;
756+ newObj . isNew = true ;
757+ }
758+ return newObj ;
759+ } ) ;
760+ }
761+ return replaceEqualDeep ( oldData , newData ) ;
762+ } ,
763+ } )
764+ ) ;
762765
763766/**
764767 * If you work with `useContentFromSearchIndex`, you can use this
0 commit comments