@@ -280,6 +280,17 @@ function invalidateReferencePreviews(
280280 } )
281281}
282282
283+ function invalidateTableNames ( queryClient : ReturnType < typeof useQueryClient > ) {
284+ queryClient . invalidateQueries ( { queryKey : tableKeys . namesRoot ( ) } )
285+ }
286+
287+ function invalidateReferenceTablePreviews (
288+ queryClient : ReturnType < typeof useQueryClient > ,
289+ tableId : string
290+ ) {
291+ queryClient . invalidateQueries ( { queryKey : tableKeys . referencePreviewsForTable ( tableId ) } )
292+ }
293+
283294/**
284295 * Invalidate only the row-count surfaces — the table detail and the tables
285296 * list, both of which carry the unfiltered `rowCount`. Deliberately leaves
@@ -304,6 +315,7 @@ function invalidateTableSchema(queryClient: ReturnType<typeof useQueryClient>, t
304315 queryClient . invalidateQueries ( { queryKey : tableKeys . detail ( tableId ) } )
305316 queryClient . invalidateQueries ( { queryKey : tableKeys . rowsRoot ( tableId ) } )
306317 queryClient . invalidateQueries ( { queryKey : tableKeys . lists ( ) } )
318+ invalidateReferenceTablePreviews ( queryClient , tableId )
307319}
308320
309321/**
@@ -321,6 +333,7 @@ function invalidateTableSchemaOnly(
321333) {
322334 queryClient . invalidateQueries ( { queryKey : tableKeys . detail ( tableId ) } )
323335 queryClient . invalidateQueries ( { queryKey : tableKeys . lists ( ) } )
336+ invalidateReferenceTablePreviews ( queryClient , tableId )
324337}
325338
326339/**
@@ -730,6 +743,7 @@ export function useCreateTable(workspaceId: string) {
730743 } ,
731744 onSettled : ( ) => {
732745 queryClient . invalidateQueries ( { queryKey : tableKeys . lists ( ) } )
746+ invalidateTableNames ( queryClient )
733747 } ,
734748 } )
735749}
@@ -779,6 +793,8 @@ export function useRenameTable(workspaceId: string) {
779793 onSettled : ( _data , _error , variables ) => {
780794 queryClient . invalidateQueries ( { queryKey : tableKeys . detail ( variables . tableId ) } )
781795 queryClient . invalidateQueries ( { queryKey : tableKeys . lists ( ) } )
796+ invalidateTableNames ( queryClient )
797+ invalidateReferenceTablePreviews ( queryClient , variables . tableId )
782798 } ,
783799 } )
784800}
@@ -889,6 +905,8 @@ export function useDeleteTable(workspaceId: string) {
889905 } ,
890906 onSettled : ( _data , _error , tableId ) => {
891907 queryClient . invalidateQueries ( { queryKey : tableKeys . lists ( ) } )
908+ invalidateTableNames ( queryClient )
909+ invalidateReferenceTablePreviews ( queryClient , tableId )
892910 queryClient . removeQueries ( { queryKey : tableKeys . detail ( tableId ) } )
893911 queryClient . removeQueries ( { queryKey : tableKeys . rowsRoot ( tableId ) } )
894912 } ,
@@ -1954,8 +1972,12 @@ export function useRestoreTable() {
19541972 onSettled : ( _data , _error , tableId ) => {
19551973 return Promise . all ( [
19561974 queryClient . invalidateQueries ( { queryKey : tableKeys . lists ( ) } ) ,
1975+ queryClient . invalidateQueries ( { queryKey : tableKeys . namesRoot ( ) } ) ,
19571976 queryClient . invalidateQueries ( { queryKey : tableKeys . detail ( tableId ) } ) ,
19581977 queryClient . invalidateQueries ( { queryKey : tableKeys . rowsRoot ( tableId ) } ) ,
1978+ queryClient . invalidateQueries ( {
1979+ queryKey : tableKeys . referencePreviewsForTable ( tableId ) ,
1980+ } ) ,
19591981 ] )
19601982 } ,
19611983 } )
@@ -2073,6 +2095,7 @@ export function useImportCsv() {
20732095 } ,
20742096 onSettled : ( ) => {
20752097 queryClient . invalidateQueries ( { queryKey : tableKeys . lists ( ) } )
2098+ invalidateTableNames ( queryClient )
20762099 } ,
20772100 } )
20782101}
@@ -2117,6 +2140,7 @@ export function useImportFileAsTable() {
21172140 } ,
21182141 onSettled : ( ) => {
21192142 queryClient . invalidateQueries ( { queryKey : tableKeys . lists ( ) } )
2143+ invalidateTableNames ( queryClient )
21202144 } ,
21212145 } )
21222146}
@@ -2784,6 +2808,8 @@ export function useBulkDeleteTables(workspaceId: string) {
27842808 } ,
27852809 onSettled : ( _data , _error , { tableIds = [ ] } ) => {
27862810 queryClient . invalidateQueries ( { queryKey : tableKeys . lists ( ) } )
2811+ invalidateTableNames ( queryClient )
2812+ queryClient . invalidateQueries ( { queryKey : tableKeys . referencePreviews ( ) } )
27872813 queryClient . invalidateQueries ( { queryKey : folderKeys . resource ( 'table' ) } )
27882814 for ( const tableId of tableIds ) {
27892815 queryClient . removeQueries ( { queryKey : tableKeys . detail ( tableId ) } )
0 commit comments