@@ -100,16 +100,14 @@ export const libraryAuthoringQueryKeys = {
100100 'blockTypes' ,
101101 libraryId ,
102102 ] ,
103- container : ( libraryId ?: string , containerId ?: string ) => [
103+ container : ( containerId ?: string ) => [
104104 ...libraryAuthoringQueryKeys . all ,
105105 'container' ,
106- libraryId ,
107106 containerId ,
108107 ] ,
109- containerChildren : ( libraryId ?: string , containerId ?: string ) => [
108+ containerChildren : ( containerId ?: string ) => [
110109 ...libraryAuthoringQueryKeys . all ,
111110 'container' ,
112- libraryId ,
113111 containerId ,
114112 'children' ,
115113 ] ,
@@ -131,14 +129,6 @@ export const xblockQueryKeys = {
131129 componentDownstreamLinks : ( usageKey : string ) => [ ...xblockQueryKeys . xblock ( usageKey ) , 'downstreamLinks' ] ,
132130} ;
133131
134- export const containerQueryKeys = {
135- all : [ 'container' , 'children' ] ,
136- /**
137- * Base key for data specific to a container
138- */
139- container : ( containerId ?: string ) => [ ...containerQueryKeys . all , containerId ] ,
140- } ;
141-
142132/**
143133 * Tell react-query to refresh its cache of any data related to the given
144134 * component (XBlock).
@@ -276,7 +266,7 @@ export const useRevertLibraryChanges = () => {
276266/**
277267 * Hook to fetch a content library's team members
278268 */
279- export const useLibraryTeam = ( libraryId : string | undefined ) => (
269+ export const useLibraryTeam = ( libraryId ? : string ) => (
280270 useQuery ( {
281271 queryKey : libraryAuthoringQueryKeys . libraryTeam ( libraryId ) ,
282272 queryFn : ( ) => getLibraryTeam ( libraryId ! ) ,
@@ -287,7 +277,7 @@ export const useLibraryTeam = (libraryId: string | undefined) => (
287277/**
288278 * Hook to fetch the list of XBlock types that can be added to this library.
289279 */
290- export const useBlockTypesMetadata = ( libraryId : string | undefined ) => (
280+ export const useBlockTypesMetadata = ( libraryId ? : string ) => (
291281 useQuery ( {
292282 queryKey : libraryAuthoringQueryKeys . blockTypes ( libraryId ) ,
293283 queryFn : ( ) => getBlockTypes ( libraryId ! ) ,
@@ -612,7 +602,7 @@ export const useCreateLibraryContainer = (libraryId: string) => {
612602export const useContainer = ( containerId ?: string ) => (
613603 useQuery ( {
614604 enabled : ! ! containerId ,
615- queryKey : containerQueryKeys . container ( containerId ) ,
605+ queryKey : libraryAuthoringQueryKeys . container ( containerId ! ) ,
616606 queryFn : ( ) => getContainerMetadata ( containerId ! ) ,
617607 } )
618608) ;
@@ -629,7 +619,7 @@ export const useUpdateContainer = (containerId: string) => {
629619 // NOTE: We invalidate the library query here because we need to update the library's
630620 // container list.
631621 queryClient . invalidateQueries ( { predicate : ( query ) => libraryQueryPredicate ( query , libraryId ) } ) ;
632- queryClient . invalidateQueries ( { queryKey : libraryAuthoringQueryKeys . containerChildren ( libraryId , containerId ) } ) ;
622+ queryClient . invalidateQueries ( { queryKey : libraryAuthoringQueryKeys . container ( containerId ) } ) ;
633623 } ,
634624 } ) ;
635625} ;
@@ -666,19 +656,18 @@ export const useRestoreContainer = (containerId: string) => {
666656/**
667657 * Get the metadata and children for a container in a library
668658 */
669- export const useContainerChildren = ( containerId : string ) => {
670- const libraryId = getLibraryId ( containerId ) ;
671- return useQuery ( {
659+ export const useContainerChildren = ( containerId ?: string ) => (
660+ useQuery ( {
672661 enabled : ! ! containerId ,
673- queryKey : libraryAuthoringQueryKeys . containerChildren ( libraryId , containerId ) ,
662+ queryKey : libraryAuthoringQueryKeys . containerChildren ( containerId ) ,
674663 queryFn : ( ) => getLibraryContainerChildren ( containerId ! ) ,
675- } ) ;
664+ } )
676665) ;
677666
678667/**
679668 * Use this mutation to add components to a container
680669 */
681- export const useAddComponentsToContainer = ( libraryId ?: string , containerId ?: string ) => {
670+ export const useAddComponentsToContainer = ( containerId ?: string ) => {
682671 const queryClient = useQueryClient ( ) ;
683672 return useMutation ( {
684673 mutationFn : async ( componentIds : string [ ] ) => {
@@ -688,7 +677,7 @@ export const useAddComponentsToContainer = (libraryId?: string, containerId?: st
688677 return undefined ;
689678 } ,
690679 onSettled : ( ) => {
691- queryClient . invalidateQueries ( { queryKey : libraryAuthoringQueryKeys . containerChildren ( libraryId , containerId ) } ) ;
680+ queryClient . invalidateQueries ( { queryKey : libraryAuthoringQueryKeys . containerChildren ( containerId ! ) } ) ;
692681 } ,
693682 } ) ;
694683} ;
0 commit comments