Update server-side cache clearing
This commit is contained in:
parent
4ef6b7d591
commit
e02fb05b75
@ -24,6 +24,7 @@ import { parseCachedPhotoDates, parseCachedPhotosDates } from '@/photo';
|
||||
import { createCameraKey } from '@/camera';
|
||||
import {
|
||||
PATHS_ADMIN,
|
||||
PATHS_TO_CACHE,
|
||||
PATH_ADMIN,
|
||||
PATH_GRID,
|
||||
PATH_ROOT,
|
||||
@ -101,15 +102,15 @@ export const revalidateAllKeys = () => {
|
||||
revalidateFilmSimulationsKey();
|
||||
};
|
||||
|
||||
export const revalidateAllKeysAndPaths = () => {
|
||||
revalidateAllKeys();
|
||||
revalidatePath('/', 'layout');
|
||||
};
|
||||
|
||||
export const revalidateAdminPaths = () => {
|
||||
PATHS_ADMIN.forEach(path => revalidatePath(path));
|
||||
};
|
||||
|
||||
export const revalidateAllKeysAndPaths = () => {
|
||||
revalidateAllKeys();
|
||||
PATHS_TO_CACHE.forEach(path => revalidatePath(path, 'layout'));
|
||||
};
|
||||
|
||||
export const revalidatePhoto = (photoId: string) => {
|
||||
// Tags
|
||||
revalidateTag(photoId);
|
||||
|
||||
@ -30,7 +30,6 @@ import { getNextImageUrlForRequest } from '@/services/next-image';
|
||||
import useDelay from '@/utility/useDelay';
|
||||
import usePreventNavigation from '@/utility/usePreventNavigation';
|
||||
import { useAppState } from '@/state/AppState';
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
const THUMBNAIL_SIZE = 300;
|
||||
|
||||
@ -66,13 +65,6 @@ export default function PhotoForm({
|
||||
|
||||
const { invalidateSwr } = useAppState();
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const clearLocalState = useCallback(() => {
|
||||
invalidateSwr?.();
|
||||
router.refresh();
|
||||
}, [invalidateSwr, router]);
|
||||
|
||||
const changedFormKeys = useMemo(() =>
|
||||
getChangedFormFields(initialPhotoForm, formData),
|
||||
[initialPhotoForm, formData]);
|
||||
@ -382,7 +374,7 @@ export default function PhotoForm({
|
||||
<SubmitButtonWithStatus
|
||||
disabled={!canFormBeSubmitted}
|
||||
onFormStatusChange={onFormStatusChange}
|
||||
onFormSubmit={clearLocalState}
|
||||
onFormSubmit={invalidateSwr}
|
||||
primary
|
||||
>
|
||||
{type === 'create' ? 'Create' : 'Update'}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user