From 4a727d35d8450e06305d284f221d43d1bf19f19f Mon Sep 17 00:00:00 2001 From: Innei Date: Fri, 31 Mar 2023 23:44:45 +0800 Subject: [PATCH] fix: after delete then toast Signed-off-by: Innei --- src/components/dashboard/PagesManager.tsx | 11 +++++++---- src/pages/dashboard/[subdomain]/posts.tsx | 9 ++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/components/dashboard/PagesManager.tsx b/src/components/dashboard/PagesManager.tsx index 0e2ffa91..baf94f3b 100644 --- a/src/components/dashboard/PagesManager.tsx +++ b/src/components/dashboard/PagesManager.tsx @@ -191,10 +191,13 @@ export const PagesManager: React.FC<{ if (!page.metadata) { const toastId = toast.loading("Deleting...") delStorage(`draft-${subdomain}-${page.id}`) - queryClient.invalidateQueries(["getPagesBySite", subdomain]) - queryClient.invalidateQueries(["getPage", page.id]) - toast.success("Deleted!", { - id: toastId, + Promise.all([ + queryClient.refetchQueries(["getPagesBySite", subdomain]), + queryClient.refetchQueries(["getPage", page.id]), + ]).then(() => { + toast.success("Deleted!", { + id: toastId, + }) }) } else { setDeleteToastId(toast.loading("Deleting...")) diff --git a/src/pages/dashboard/[subdomain]/posts.tsx b/src/pages/dashboard/[subdomain]/posts.tsx index 1334c4b5..3648ff09 100644 --- a/src/pages/dashboard/[subdomain]/posts.tsx +++ b/src/pages/dashboard/[subdomain]/posts.tsx @@ -1,9 +1,8 @@ -import { DashboardLayout } from "~/components/dashboard/DashboardLayout" -import { PagesManager } from "~/components/dashboard/PagesManager" -import type { ReactElement } from "react" -import { useTranslation } from "next-i18next" -import { getServerSideProps as getLayoutServerSideProps } from "~/components/dashboard/DashboardLayout.server" import { GetServerSideProps } from "next" +import type { ReactElement } from "react" +import { DashboardLayout } from "~/components/dashboard/DashboardLayout" +import { getServerSideProps as getLayoutServerSideProps } from "~/components/dashboard/DashboardLayout.server" +import { PagesManager } from "~/components/dashboard/PagesManager" import { serverSidePropsHandler } from "~/lib/server-side-props" export const getServerSideProps: GetServerSideProps = serverSidePropsHandler(