Skip to content

Commit fcb30a3

Browse files
committed
fix: fix website list not refresh when delete website problem
1 parent cc581f9 commit fcb30a3

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ It's good to specialize in one thing, if we are experts in related abilities we
3838
- [ ] survey
3939
- [ ] lighthouse report
4040
- [ ] hooks
41+
- [ ] links
4142

4243
## Preview
4344

src/client/components/website/WebsiteConfig.tsx

+9-7
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ import { MonitorPicker } from '../monitor/MonitorPicker';
1010
import {
1111
defaultErrorHandler,
1212
defaultSuccessHandler,
13-
getQueryKey,
1413
trpc,
1514
} from '../../api/trpc';
16-
import { useQueryClient } from '@tanstack/react-query';
1715
import { useEvent } from '../../hooks/useEvent';
1816
import { hostnameValidator } from '../../utils/validator';
1917
import { useTranslation } from '@i18next-toolkit/react';
@@ -25,18 +23,15 @@ export const WebsiteConfig: React.FC<{ websiteId: string }> = React.memo(
2523
const { t } = useTranslation();
2624
const workspaceId = useCurrentWorkspaceId();
2725
const navigate = useNavigate();
28-
const queryClient = useQueryClient();
26+
const trpcUtils = trpc.useUtils();
2927

3028
const { data: website, isLoading } = trpc.website.info.useQuery({
3129
workspaceId,
3230
websiteId,
3331
});
3432

3533
const updateMutation = trpc.website.updateInfo.useMutation({
36-
onSuccess: () => {
37-
queryClient.resetQueries(getQueryKey(trpc.website.info));
38-
defaultSuccessHandler();
39-
},
34+
onSuccess: defaultSuccessHandler,
4035
onError: defaultErrorHandler,
4136
});
4237

@@ -49,6 +44,11 @@ export const WebsiteConfig: React.FC<{ websiteId: string }> = React.memo(
4944
domain: values.domain,
5045
monitorId: values.monitorId,
5146
});
47+
48+
trpcUtils.website.info.refetch({
49+
workspaceId,
50+
websiteId,
51+
});
5252
}
5353
);
5454

@@ -57,6 +57,8 @@ export const WebsiteConfig: React.FC<{ websiteId: string }> = React.memo(
5757

5858
message.success(t('Delete Success'));
5959

60+
await trpcUtils.website.all.refetch({ workspaceId });
61+
6062
navigate({
6163
to: '/website',
6264
});

src/client/routes/__root.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createRootRouteWithContext, Outlet } from '@tanstack/react-router';
2-
import { TanStackRouterDevtools } from '@tanstack/router-devtools';
2+
// import { TanStackRouterDevtools } from '@tanstack/router-devtools';
33
import { Suspense } from 'react';
44

55
interface RouterContext {
@@ -13,7 +13,8 @@ export const Route = createRootRouteWithContext<RouterContext>()({
1313
// https://github.com/TanStack/router/issues/857
1414
<Suspense fallback={null}>
1515
<Outlet />
16-
<TanStackRouterDevtools position="bottom-right" />
16+
17+
{/* <TanStackRouterDevtools position="bottom-right" /> */}
1718
</Suspense>
1819
);
1920
},

0 commit comments

Comments
 (0)