@@ -50,9 +50,32 @@ const EmptyState = () => (
5050)
5151
5252SnapshotsPage . loader = async ( { params } : LoaderFunctionArgs ) => {
53- await apiQueryClient . prefetchQuery ( 'snapshotList' , {
54- query : { ...getProjectSelector ( params ) , limit : 25 } ,
55- } )
53+ const { project } = getProjectSelector ( params )
54+ await Promise . all ( [
55+ apiQueryClient . prefetchQuery ( 'snapshotList' , {
56+ query : { project, limit : 25 } ,
57+ } ) ,
58+
59+ // Fetch disks and preload into RQ cache so fetches by ID in DiskNameFromId
60+ // can be mostly instant yet gracefully fall back to fetching individually
61+ // if we don't fetch them all here. This has to be the *ErrorsAllowed
62+ // version of setQueryData because the disk fetchs are also the errors
63+ // allowed version. If we use regular setQueryData, nothing blows up; the
64+ // data is just never found in the cache. Note that the disks that error
65+ // (delete disks) are not prefetched here because they are (obviously) not
66+ // in the disk list response.
67+ apiQueryClient
68+ . fetchQuery ( 'diskList' , { query : { project, limit : 200 } } )
69+ . then ( ( disks ) => {
70+ for ( const disk of disks . items ) {
71+ apiQueryClient . setQueryDataErrorsAllowed (
72+ 'diskView' ,
73+ { path : { disk : disk . id } } ,
74+ { type : 'success' , data : disk }
75+ )
76+ }
77+ } ) ,
78+ ] )
5679 return null
5780}
5881
0 commit comments