From fd600ced09ad2f42031498d71f2b63540f6dffdf Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 15 Aug 2023 21:39:01 +0200 Subject: [PATCH] fix: Flash of 'not found' screen when deleting a collection --- app/components/CollectionDeleteDialog.tsx | 9 +++++++-- shared/i18n/locales/en_US/translation.json | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/components/CollectionDeleteDialog.tsx b/app/components/CollectionDeleteDialog.tsx index f51da8ed26..1468faa1ff 100644 --- a/app/components/CollectionDeleteDialog.tsx +++ b/app/components/CollectionDeleteDialog.tsx @@ -7,6 +7,7 @@ import ConfirmationDialog from "~/components/ConfirmationDialog"; import Text from "~/components/Text"; import useCurrentTeam from "~/hooks/useCurrentTeam"; import useStores from "~/hooks/useStores"; +import useToasts from "~/hooks/useToasts"; import { homePath } from "~/utils/routeHelpers"; type Props = { @@ -17,16 +18,20 @@ type Props = { function CollectionDeleteDialog({ collection, onSubmit }: Props) { const team = useCurrentTeam(); const { ui } = useStores(); + const { showToast } = useToasts(); const history = useHistory(); const { t } = useTranslation(); const handleSubmit = async () => { const redirect = collection.id === ui.activeCollectionId; - await collection.delete(); - onSubmit(); + if (redirect) { history.push(homePath()); } + + await collection.delete(); + onSubmit(); + showToast(t("Collection deleted"), { type: "success" }); }; return ( diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index dc3634231d..7ab62ccd91 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -105,6 +105,7 @@ "previously edited": "previously edited", "You": "You", "Viewers": "Viewers", + "Collection deleted": "Collection deleted", "I’m sure – Delete": "I’m sure – Delete", "Deleting": "Deleting", "Are you sure about that? Deleting the {{collectionName}} collection is permanent and cannot be restored, however all published documents within will be moved to the trash.": "Are you sure about that? Deleting the {{collectionName}} collection is permanent and cannot be restored, however all published documents within will be moved to the trash.",