fix: Flash of 'not found' screen when deleting a collection
This commit is contained in:
@@ -7,6 +7,7 @@ import ConfirmationDialog from "~/components/ConfirmationDialog";
|
|||||||
import Text from "~/components/Text";
|
import Text from "~/components/Text";
|
||||||
import useCurrentTeam from "~/hooks/useCurrentTeam";
|
import useCurrentTeam from "~/hooks/useCurrentTeam";
|
||||||
import useStores from "~/hooks/useStores";
|
import useStores from "~/hooks/useStores";
|
||||||
|
import useToasts from "~/hooks/useToasts";
|
||||||
import { homePath } from "~/utils/routeHelpers";
|
import { homePath } from "~/utils/routeHelpers";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -17,16 +18,20 @@ type Props = {
|
|||||||
function CollectionDeleteDialog({ collection, onSubmit }: Props) {
|
function CollectionDeleteDialog({ collection, onSubmit }: Props) {
|
||||||
const team = useCurrentTeam();
|
const team = useCurrentTeam();
|
||||||
const { ui } = useStores();
|
const { ui } = useStores();
|
||||||
|
const { showToast } = useToasts();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
const redirect = collection.id === ui.activeCollectionId;
|
const redirect = collection.id === ui.activeCollectionId;
|
||||||
await collection.delete();
|
|
||||||
onSubmit();
|
|
||||||
if (redirect) {
|
if (redirect) {
|
||||||
history.push(homePath());
|
history.push(homePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await collection.delete();
|
||||||
|
onSubmit();
|
||||||
|
showToast(t("Collection deleted"), { type: "success" });
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -105,6 +105,7 @@
|
|||||||
"previously edited": "previously edited",
|
"previously edited": "previously edited",
|
||||||
"You": "You",
|
"You": "You",
|
||||||
"Viewers": "Viewers",
|
"Viewers": "Viewers",
|
||||||
|
"Collection deleted": "Collection deleted",
|
||||||
"I’m sure – Delete": "I’m sure – Delete",
|
"I’m sure – Delete": "I’m sure – Delete",
|
||||||
"Deleting": "Deleting",
|
"Deleting": "Deleting",
|
||||||
"Are you sure about that? Deleting the <em>{{collectionName}}</em> 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 <em>{{collectionName}}</em> 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 <em>{{collectionName}}</em> 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 <em>{{collectionName}}</em> collection is permanent and cannot be restored, however all published documents within will be moved to the trash.",
|
||||||
|
|||||||
Reference in New Issue
Block a user