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