fix: routing issues (#590)

This commit is contained in:
2023-02-26 15:25:27 +01:00
committed by GitHub
parent e793a50a92
commit 4bee8f2e0b
9 changed files with 37 additions and 57 deletions

View File

@ -1,18 +0,0 @@
import { history } from '../routing/history';
import { getCollectionUrl, getNewEntryUrl } from '../lib/urlHelper';
export function searchCollections(query: string, collection?: string) {
if (collection) {
history.push(`/collections/${collection}/search/${query}`);
} else {
history.push(`/search/${query}`);
}
}
export function showCollection(collectionName: string) {
history.push(getCollectionUrl(collectionName));
}
export function createNewEntry(collectionName: string) {
history.push(getNewEntryUrl(collectionName));
}

View File

@ -1,4 +1,5 @@
import isEqual from 'lodash/isEqual';
import { redirect } from 'react-router-dom';
import { currentBackend } from '../backend';
import {
@ -48,7 +49,6 @@ import {
selectIsFetching,
selectPublishedSlugs,
} from '../reducers/selectors/entries';
import { navigateToEntry } from '../routing/history';
import { addSnackbar } from '../store/slices/snackbars';
import { createAssetProxy } from '../valueObjects/AssetProxy';
import createEntry from '../valueObjects/createEntry';
@ -1040,7 +1040,7 @@ export function persistEntry(collection: Collection) {
}
if (entry.slug !== newSlug) {
await dispatch(loadEntry(collection, newSlug));
navigateToEntry(collection.name, newSlug);
redirect(`/collections/${collection.name}/entries/${newSlug}`);
} else {
await dispatch(loadEntry(collection, newSlug, true));
}