Redirect to canonical photo path when un-favoriting

This commit is contained in:
Sam Becker 2024-03-14 13:03:31 -05:00
parent e3cd0e59cd
commit fb393f4fc4
2 changed files with 8 additions and 2 deletions

View File

@ -20,6 +20,7 @@ export default function AdminPhotoMenuClient({
const path = usePathname();
const shouldRedirectFav = isPathFavs(path) && isFav;
const shouldRedirectDelete = pathForPhoto(photo.id) === path;
return (
<>
<MoreMenu {...{

View File

@ -24,7 +24,12 @@ import {
revalidatePhotosKey,
revalidateTagsKey,
} from '@/photo/cache';
import { PATH_ADMIN_PHOTOS, PATH_ADMIN_TAGS, PATH_ROOT } from '@/site/paths';
import {
PATH_ADMIN_PHOTOS,
PATH_ADMIN_TAGS,
PATH_ROOT,
pathForPhoto,
} from '@/site/paths';
import { extractExifDataFromBlobPath } from './server';
import { TAG_FAVS, isTagFavs } from '@/tag';
import { convertPhotoToPhotoDbInsert } from '.';
@ -66,7 +71,7 @@ export async function toggleFavoritePhotoAction(
await sqlUpdatePhoto(convertPhotoToPhotoDbInsert(photo));
revalidateAllKeysAndPaths();
if (shouldRedirect) {
redirect(PATH_ROOT);
redirect(pathForPhoto(photoId));
}
}
}