Skip to content

Commit

Permalink
on instance delete success, invalidate instance list before navigating
Browse files Browse the repository at this point in the history
  • Loading branch information
david-crespo committed Aug 20, 2024
1 parent 6d2fdf7 commit a02992b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
12 changes: 3 additions & 9 deletions app/pages/project/instances/InstancesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ import { filesize } from 'filesize'
import { useMemo } from 'react'
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'

import {
apiQueryClient,
useApiQueryClient,
usePrefetchedApiQuery,
type Instance,
} from '@oxide/api'
import { apiQueryClient, usePrefetchedApiQuery, type Instance } from '@oxide/api'
import { Instances16Icon, Instances24Icon } from '@oxide/design-system/icons/react'

import { DocsPopover } from '~/components/DocsPopover'
Expand Down Expand Up @@ -55,12 +50,11 @@ InstancesPage.loader = async ({ params }: LoaderFunctionArgs) => {
return null
}

const refetchInstances = () => apiQueryClient.invalidateQueries('instanceList')

export function InstancesPage() {
const { project } = useProjectSelector()

const queryClient = useApiQueryClient()
const refetchInstances = () => queryClient.invalidateQueries('instanceList')

const makeActions = useMakeInstanceActions(
{ project },
{ onSuccess: refetchInstances, onDelete: refetchInstances }
Expand Down
5 changes: 4 additions & 1 deletion app/pages/project/instances/instance/InstancePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ export function InstancePage() {
const makeActions = useMakeInstanceActions(instanceSelector, {
onSuccess: refreshData,
// go to project instances list since there's no more instance
onDelete: () => navigate(pb.instances(instanceSelector)),
onDelete: () => {
apiQueryClient.invalidateQueries('instanceList')
navigate(pb.instances(instanceSelector))
},
})

const { data: instance } = usePrefetchedApiQuery(
Expand Down

0 comments on commit a02992b

Please sign in to comment.