Skip to content

Commit

Permalink
better invalidation
Browse files Browse the repository at this point in the history
  • Loading branch information
charliepark committed Sep 7, 2024
1 parent 4b07857 commit 4052aee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
9 changes: 0 additions & 9 deletions app/forms/ip-pool-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,6 @@ export function EditIpPoolSideModalForm() {
queryClient.invalidateQueries('ipPoolList')
navigate(pb.ipPool({ pool: updatedPool.name }))
addToast({ content: 'Your IP pool has been updated' })

// Only invalidate if we're staying on the same page. If the name
// _has_ changed, invalidating ipPoolView causes an error page to flash
// while the loader for the target page is running because the current
// page's pool gets cleared out while we're still on the page. If we're
// navigating to a different page, its query will fetch anew regardless.
if (pool.name === updatedPool.name) {
queryClient.invalidateQueries('ipPoolView')
}
},
})

Expand Down
10 changes: 8 additions & 2 deletions app/pages/project/vpcs/VpcPage/VpcPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
import { useMemo } from 'react'
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'

import { apiQueryClient, useApiMutation, usePrefetchedApiQuery } from '@oxide/api'
import {
apiQueryClient,
useApiMutation,
useApiQueryClient,
usePrefetchedApiQuery,
} from '@oxide/api'
import { Networking24Icon } from '@oxide/design-system/icons/react'

import { MoreActionsMenu } from '~/components/MoreActionsMenu'
Expand All @@ -31,6 +36,7 @@ VpcPage.loader = async ({ params }: LoaderFunctionArgs) => {
}

export function VpcPage() {
const queryClient = useApiQueryClient()
const navigate = useNavigate()
const vpcSelector = useVpcSelector()
const { project, vpc: vpcName } = vpcSelector
Expand All @@ -41,8 +47,8 @@ export function VpcPage() {

const { mutateAsync: deleteVpc } = useApiMutation('vpcDelete', {
onSuccess() {
queryClient.invalidateQueries('vpcList')
navigate(pb.vpcs({ project }))
apiQueryClient.invalidateQueries('vpcList')
addToast({ content: 'VPC deleted' })
},
})
Expand Down

0 comments on commit 4052aee

Please sign in to comment.