Remove cache clearing from admin server pages
This commit is contained in:
parent
2c1b39fb30
commit
232a7dd67a
@ -34,7 +34,6 @@ import MoreComponentsFromSearchParams from
|
|||||||
import { getPhotos } from '@/services/vercel-postgres';
|
import { getPhotos } from '@/services/vercel-postgres';
|
||||||
import PhotoDate from '@/photo/PhotoDate';
|
import PhotoDate from '@/photo/PhotoDate';
|
||||||
import { revalidatePath } from 'next/cache';
|
import { revalidatePath } from 'next/cache';
|
||||||
import useSwrClear from '@/state/useSwrClear';
|
|
||||||
|
|
||||||
const DEBUG_PHOTO_BLOBS = false;
|
const DEBUG_PHOTO_BLOBS = false;
|
||||||
|
|
||||||
@ -55,8 +54,6 @@ export default async function AdminPhotosPage({
|
|||||||
|
|
||||||
const showMorePhotos = count > photos.length;
|
const showMorePhotos = count > photos.length;
|
||||||
|
|
||||||
const clearSwr = useSwrClear();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SiteGrid
|
<SiteGrid
|
||||||
contentMain={
|
contentMain={
|
||||||
@ -130,7 +127,6 @@ export default async function AdminPhotosPage({
|
|||||||
`for "${titleForPhoto(photo)}" from source file? ` +
|
`for "${titleForPhoto(photo)}" from source file? ` +
|
||||||
'This action cannot be undone.'
|
'This action cannot be undone.'
|
||||||
}
|
}
|
||||||
onSubmit={clearSwr}
|
|
||||||
>
|
>
|
||||||
<input type="hidden" name="id" value={photo.id} />
|
<input type="hidden" name="id" value={photo.id} />
|
||||||
<SubmitButtonWithStatus
|
<SubmitButtonWithStatus
|
||||||
@ -138,13 +134,11 @@ export default async function AdminPhotosPage({
|
|||||||
onFormSubmitToastMessage={`
|
onFormSubmitToastMessage={`
|
||||||
"${titleForPhoto(photo)}" EXIF data synced
|
"${titleForPhoto(photo)}" EXIF data synced
|
||||||
`}
|
`}
|
||||||
onSubmit={clearSwr}
|
|
||||||
/>
|
/>
|
||||||
</FormWithConfirm>
|
</FormWithConfirm>
|
||||||
<FormWithConfirm
|
<FormWithConfirm
|
||||||
action={deletePhotoFormAction}
|
action={deletePhotoFormAction}
|
||||||
confirmText={deleteConfirmationTextForPhoto(photo)}
|
confirmText={deleteConfirmationTextForPhoto(photo)}
|
||||||
onSubmit={clearSwr}
|
|
||||||
>
|
>
|
||||||
<input type="hidden" name="id" value={photo.id} />
|
<input type="hidden" name="id" value={photo.id} />
|
||||||
<input type="hidden" name="url" value={photo.url} />
|
<input type="hidden" name="url" value={photo.url} />
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { useSWRConfig } from 'swr';
|
import { useSWRConfig } from 'swr';
|
||||||
|
|
||||||
export default function useSwrClear() {
|
export default function useSwrClear() {
|
||||||
const { mutate } = useSWRConfig();
|
const { mutate } = useSWRConfig();
|
||||||
return useCallback(() => mutate(
|
return useCallback(() => mutate(
|
||||||
_key => false,
|
_key => true,
|
||||||
undefined,
|
undefined,
|
||||||
{ revalidate: false },
|
{ revalidate: false },
|
||||||
), [mutate]);
|
), [mutate]);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user