fix: invalidate queries better
This commit is contained in:
@@ -47,7 +47,7 @@ export default function AddDashboard() {
|
||||
toast('Success', {
|
||||
description: 'Dashboard created.',
|
||||
});
|
||||
queryClient.invalidateQueries(trpc.dashboard.pathFilter());
|
||||
queryClient.invalidateQueries(trpc.dashboard.list.pathFilter());
|
||||
popModal();
|
||||
},
|
||||
onError: handleError,
|
||||
|
||||
@@ -56,6 +56,7 @@ export default function SaveReport({
|
||||
projectId,
|
||||
}),
|
||||
);
|
||||
queryClient.invalidateQueries(trpc.dashboard.list.pathFilter());
|
||||
|
||||
const goToReport = () => {
|
||||
router.navigate({
|
||||
@@ -157,6 +158,7 @@ function SelectDashboard({
|
||||
projectId: string;
|
||||
}) {
|
||||
const trpc = useTRPC();
|
||||
const queryClient = useQueryClient();
|
||||
const [isCreatingNew, setIsCreatingNew] = useState(false);
|
||||
const [newDashboardName, setNewDashboardName] = useState('');
|
||||
|
||||
@@ -177,6 +179,7 @@ function SelectDashboard({
|
||||
trpc.dashboard.create.mutationOptions({
|
||||
onError: handleError,
|
||||
async onSuccess(res) {
|
||||
queryClient.invalidateQueries(trpc.dashboard.list.pathFilter());
|
||||
await dashboardQuery.refetch();
|
||||
onChange(res.id);
|
||||
setIsCreatingNew(false);
|
||||
|
||||
@@ -29,7 +29,7 @@ import FullPageLoadingState from '@/components/full-page-loading-state';
|
||||
import { PageContainer } from '@/components/page-container';
|
||||
import { PageHeader } from '@/components/page-header';
|
||||
import { handleErrorToastOptions, useTRPC } from '@/integrations/trpc/react';
|
||||
import { useMutation, useQuery } from '@tanstack/react-query';
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { Link, createFileRoute } from '@tanstack/react-router';
|
||||
|
||||
export const Route = createFileRoute(
|
||||
@@ -58,6 +58,7 @@ export const Route = createFileRoute(
|
||||
function Component() {
|
||||
const { projectId } = Route.useParams();
|
||||
const trpc = useTRPC();
|
||||
const queryClient = useQueryClient();
|
||||
const query = useQuery(
|
||||
trpc.dashboard.list.queryOptions({
|
||||
projectId,
|
||||
@@ -80,6 +81,7 @@ function Component() {
|
||||
})(error);
|
||||
},
|
||||
onSuccess() {
|
||||
queryClient.invalidateQueries(trpc.dashboard.list.pathFilter());
|
||||
query.refetch();
|
||||
toast('Success', {
|
||||
description: 'Dashboard deleted.',
|
||||
|
||||
@@ -35,7 +35,7 @@ import {
|
||||
} from '@/components/report/report-item';
|
||||
import { handleErrorToastOptions, useTRPC } from '@/integrations/trpc/react';
|
||||
import { pushModal, showConfirm } from '@/modals';
|
||||
import { useMutation, useQuery } from '@tanstack/react-query';
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { createFileRoute, useRouter } from '@tanstack/react-router';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
@@ -85,6 +85,7 @@ function Component() {
|
||||
const router = useRouter();
|
||||
const { organizationId, dashboardId, projectId } = Route.useParams();
|
||||
const trpc = useTRPC();
|
||||
const queryClient = useQueryClient();
|
||||
const { range, startDate, endDate, interval } = useOverviewOptions();
|
||||
|
||||
const dashboardQuery = useQuery(
|
||||
@@ -105,6 +106,7 @@ function Component() {
|
||||
trpc.dashboard.delete.mutationOptions({
|
||||
onError: handleErrorToastOptions({}),
|
||||
onSuccess() {
|
||||
queryClient.invalidateQueries(trpc.dashboard.list.pathFilter());
|
||||
toast('Dashboard deleted');
|
||||
router.navigate({
|
||||
to: '/$organizationId/$projectId/dashboards',
|
||||
@@ -139,6 +141,7 @@ function Component() {
|
||||
trpc.report.delete.mutationOptions({
|
||||
onError: handleErrorToastOptions({}),
|
||||
onSuccess() {
|
||||
queryClient.invalidateQueries(trpc.dashboard.list.pathFilter());
|
||||
reportsQuery.refetch();
|
||||
toast('Report deleted');
|
||||
},
|
||||
@@ -149,6 +152,7 @@ function Component() {
|
||||
trpc.report.duplicate.mutationOptions({
|
||||
onError: handleErrorToastOptions({}),
|
||||
onSuccess() {
|
||||
queryClient.invalidateQueries(trpc.dashboard.list.pathFilter());
|
||||
reportsQuery.refetch();
|
||||
toast('Report duplicated');
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user